Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintenance for V0.2.0 release #148

Merged
merged 9 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/).

[0.1.X] - 2024-XX-XX
[0.2.0] - 2024-XX-XX
--------------------
* Maintenance
* Removed unneeded keyword arguments from Kp method functions
Expand All @@ -12,6 +12,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
* Added `verify=False` to GFZ requests
* Updated documentation links and fixed intersphinx mapping
* Replaced `utcnow` with `now` and the UTC timezone
* Removed support for deprecated Kp tag, ''
* Updated minimum supported pysat version to 3.2.0+.
* Bugs
* Fixed errors introduced by assuming files will be present when combining
F10.7 or Kp data in `combine_f107` and `combine_kp` functions.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Python 3.7+.

| Common modules | Community modules |
| -------------- | ----------------- |
| netCDF4 | pysat >= 3.1.0 |
| netCDF4 | pysat >= 3.2.0 |
| numpy | |
| pandas | |
| requests | |
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Python 3.6 and 3.9+.
============== =================
Common modules Community modules
============== =================
netCDF4 pysat >= 3.1.0
netCDF4 pysat >= 3.2.0
numpy
pandas
requests
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencies = [
"numpy",
"packaging",
"pandas",
"pysat>=3.1.0",
"pysat>=3.2.0",
"requests",
"xarray"]

Expand Down
17 changes: 1 addition & 16 deletions pysatSpaceWeather/instruments/methods/f107.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import datetime as dt
import numpy as np
from packaging.version import Version

import pandas as pds
import pysat
Expand Down Expand Up @@ -172,12 +171,6 @@ def combine_f107(standard_inst, forecast_inst, start=None, stop=None):
# Set the load kwargs, which vary by pysat version and tag
load_kwargs = {'date': itime}

# TODO(#131): Remove version check after minimum version
# supported is 3.2.0
if all([Version(pysat.__version__) > Version('3.0.1'),
Version(pysat.__version__) < Version('3.2.0')]):
load_kwargs['use_header'] = True

if standard_inst.tag == 'daily':
# Add 30 days
load_kwargs['date'] += dt.timedelta(days=30)
Expand Down Expand Up @@ -225,15 +218,7 @@ def combine_f107(standard_inst, forecast_inst, start=None, stop=None):
# data
for filename in files:
if filename is not None:
load_kwargs = {'fname': filename}

# TODO(#131): Remove version check after minimum version
# supported is 3.2.0
if all([Version(pysat.__version__) > Version('3.0.1'),
Version(pysat.__version__) < Version('3.2.0')]):
load_kwargs['use_header'] = True

forecast_inst.load(**load_kwargs)
forecast_inst.load(fname=filename)

if notes.find("forecast") < 0:
notes += " the {:} source ({:} to ".format(inst_flag,
Expand Down
55 changes: 10 additions & 45 deletions pysatSpaceWeather/instruments/methods/kp_ap.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import datetime as dt
import numpy as np
from packaging.version import Version
import pandas as pds

import pysat
Expand All @@ -36,8 +35,7 @@ def acknowledgements(name, tag):

"""

ackn = {'kp': {'': 'Provided by GFZ German Research Centre for Geosciences',
'forecast': swpc.ackn, 'recent': swpc.ackn, 'def': gfz.ackn,
ackn = {'kp': {'forecast': swpc.ackn, 'recent': swpc.ackn, 'def': gfz.ackn,
'now': gfz.ackn, 'prediction': swpc.ackn},
'ap': {'forecast': swpc.ackn, 'recent': swpc.ackn,
'prediction': swpc.ackn, '45day': swpc.ackn,
Expand Down Expand Up @@ -81,7 +79,7 @@ def references(name, tag):
"and availability, Rev. Geophys. 29, 3, ",
"415-432, 1991."])])

refs = {'kp': {'': gen_refs, 'forecast': gen_refs, 'recent': gen_refs,
refs = {'kp': {'forecast': gen_refs, 'recent': gen_refs,
'prediction': gen_refs, 'def': gfz.geoind_refs,
'now': gfz.geoind_refs},
'ap': {'recent': gen_refs, 'forecast': gen_refs, '45day': gen_refs,
Expand Down Expand Up @@ -363,8 +361,9 @@ def filter_geomag(inst, min_kp=0, max_kp=9, filter_time=24, kp_inst=None,
Default max and min values accept all Kp, so changing only one will cause
the filter to act as a high- or low-pass function.

This routine is written for standard Kp data (tag=''), not the forecast or
recent data. However, it will work with these Kp data if they are supplied.
This routine is written for standard Kp data (tags of 'def', 'now'), not
the forecast or recent data. However, it will work with these Kp data if
they are supplied.

"""
# Load the desired data
Expand All @@ -375,13 +374,6 @@ def filter_geomag(inst, min_kp=0, max_kp=9, filter_time=24, kp_inst=None,
if kp_inst.empty:
load_kwargs = {'date': inst.index[0], 'end_date': inst.index[-1],
'verifyPad': True}

# TODO(#131): Remove version check after minimum version supported
# is 3.2.0
if all([Version(pysat.__version__) > Version('3.0.1'),
Version(pysat.__version__) < Version('3.2.0')]):
load_kwargs['use_header'] = True

kp_inst.load(**load_kwargs)

if kp_inst.empty:
Expand Down Expand Up @@ -590,13 +582,8 @@ def combine_kp(standard_inst=None, recent_inst=None, forecast_inst=None,
"provide starting and ending times")))

# Initialize the output instrument
# TODO(#136): Remove if/else when pysat is 3.2.0+
if hasattr(all_inst[0], "meta_labels"):
meta_kwargs = {"labels": all_inst[0].meta_labels}
kp_inst = pysat.Instrument(labels=all_inst[0].meta_labels)
else:
meta_kwargs = all_inst[0].meta_kwargs
kp_inst = pysat.Instrument(meta_kwargs=meta_kwargs)
meta_kwargs = all_inst[0].meta_kwargs
kp_inst = pysat.Instrument(meta_kwargs=meta_kwargs)

kp_inst.inst_module = pysat_sw.instruments.sw_kp
kp_inst.tag = tag
Expand All @@ -613,15 +600,7 @@ def combine_kp(standard_inst=None, recent_inst=None, forecast_inst=None,
while itime < stop and inst_flag is not None:
# Load and save the standard data for as many times as possible
if inst_flag == 'standard':
load_kwargs = {'date': itime}

# TODO(#131): Remove version check after minimum version supported
# is 3.2.0
if all([Version(pysat.__version__) > Version('3.0.1'),
Version(pysat.__version__) < Version('3.2.0')]):
load_kwargs['use_header'] = True

standard_inst.load(**load_kwargs)
standard_inst.load(date=itime)

if notes.find("standard") < 0:
notes += " the {:} source ({:} to ".format(inst_flag,
Expand Down Expand Up @@ -650,14 +629,7 @@ def combine_kp(standard_inst=None, recent_inst=None, forecast_inst=None,
# data
for filename in files:
if filename is not None:
load_kwargs = {'fname': filename}

# TODO(#131): Remove version check after minimum version
# supported is 3.2.0
if all([Version(pysat.__version__) > Version('3.0.1'),
Version(pysat.__version__) < Version('3.2.0')]):
load_kwargs['use_header'] = True
recent_inst.load(**load_kwargs)
recent_inst.load(fname=filename)

if notes.find("recent") < 0:
notes += " the {:} source ({:} to ".format(inst_flag,
Expand Down Expand Up @@ -699,14 +671,7 @@ def combine_kp(standard_inst=None, recent_inst=None, forecast_inst=None,
# data
for filename in files:
if filename is not None:
load_kwargs = {'fname': filename}

# TODO(#131): Remove version check after minimum version
# supported is 3.2.0
if all([Version(pysat.__version__) > Version('3.0.1'),
Version(pysat.__version__) < Version('3.2.0')]):
load_kwargs['use_header'] = True
forecast_inst.load(**load_kwargs)
forecast_inst.load(fname=filename)

if notes.find("forecast") < 0:
notes += " the {:} source ({:} to ".format(inst_flag,
Expand Down
Loading
Loading