Skip to content

Commit

Permalink
Merge pull request #235 from pysat/maint/future_warn_2024
Browse files Browse the repository at this point in the history
MAINT: Future Warnings for numpy, pandas, pysat
  • Loading branch information
jklenzing authored Jul 17, 2024
2 parents 888eec6 + 00b0d52 commit c9d6fde
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:

name: Documentation tests
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
name: Python ${{ matrix.python-version }} on ${{ matrix.os }} with numpy ${{ matrix.numpy_ver }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pip_rc_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pysat_rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
* Added version cap for sphinx_rtd_theme
* Include standard tests for ICON IVM-B
* Update NEP29 standards for Jun 2024
* Updated standards for pandas, numpy, and pysat
* Updated versions in GitHub Actions

## [0.0.5] - 2023-06-27
* New Instruments
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ markers = [
"download",
"no_download",
"load_options",
"new_tests",
"first",
"second"
]
2 changes: 1 addition & 1 deletion pysatNASA/instruments/de2_vefi.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def load(fnames, tag='', inst_id='', **kwargs):
if tag == '':
# Warn user that e-field data is dropped.
estr = 'E-field data dropped'
pysat.logger.warn(estr)
pysat.logger.warning(estr)

# Drop E-field data
if 'use_cdflib' in kwargs.keys():
Expand Down
14 changes: 7 additions & 7 deletions pysatNASA/instruments/methods/cdaweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def load(fnames, tag='', inst_id='', file_cadence=dt.timedelta(days=1),
else:
if not use_cdflib:
estr = 'The `use_cdflib` option is not currently enabled for xarray'
pysat.logger.warn(estr)
pysat.logger.warning(estr)

data, meta = load_xarray(fnames, tag=tag, inst_id=inst_id,
epoch_name=epoch_name,
Expand Down Expand Up @@ -264,8 +264,8 @@ def load_pandas(fnames, tag='', inst_id='', file_cadence=dt.timedelta(days=1),
tdata = tdata.loc[date:date2, :]
ldata.append(tdata)
except ValueError as verr:
logger.warn("unable to load {:}: {:}".format(fname,
str(verr)))
logger.warning(
"unable to load {:}: {:}".format(fname, str(verr)))
else:
# Basic data return
with CDF(lfname) as cdf:
Expand All @@ -274,8 +274,8 @@ def load_pandas(fnames, tag='', inst_id='', file_cadence=dt.timedelta(days=1),
flatten_twod=flatten_twod)
ldata.append(temp_data)
except ValueError as verr:
logger.warn("unable to load {:}: {:}".format(lfname,
str(verr)))
logger.warning(
"unable to load {:}: {:}".format(lfname, str(verr)))

# Combine individual files together
if len(ldata) > 0:
Expand Down Expand Up @@ -847,7 +847,7 @@ def list_remote_files(tag='', inst_id='', start=None, stop=None,
if 'month' in search_dir['keys']:
search_times = pds.date_range(start,
stop + pds.DateOffset(months=1),
freq='M')
freq='ME')
for time in search_times:
subdir = format_dir.format(year=time.year, month=time.month)
url_list.append('/'.join((remote_url, subdir)))
Expand All @@ -859,7 +859,7 @@ def list_remote_files(tag='', inst_id='', start=None, stop=None,
else:
search_times = pds.date_range(start, stop
+ pds.DateOffset(years=1),
freq='Y')
freq='YE')
for time in search_times:
doy = int(time.strftime('%j'))
subdir = format_dir.format(year=time.year, day=doy)
Expand Down
8 changes: 4 additions & 4 deletions pysatNASA/instruments/methods/jhuapl.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,15 @@ def load_sdr_aurora(fnames, name='', tag='', inst_id='', pandas_format=False,

# Ensure identical day and night dimensions for GUVI
if name == 'guvi':
if sdata.dims['nAlongDay'] != sdata.dims['nAlongNight']:
if sdata.sizes['nAlongDay'] != sdata.sizes['nAlongNight']:
raise ValueError('Along-track day and night dimensions differ')

if 'nCrossDay' in rename_dims.keys():
if sdata.dims['nCrossDay'] != sdata.dims['nCrossNight']:
if sdata.sizes['nCrossDay'] != sdata.sizes['nCrossNight']:
raise ValueError(''.join([
'Cross-track day and night dimensions differ ',
'{:} != {:}'.format(sdata.dims['nCrossDay'],
sdata.dims['nCrossNight'])]))
'{:} != {:}'.format(sdata.sizes['nCrossDay'],
sdata.sizes['nCrossNight'])]))

# Combine identical dimensions and rename some time dimensions
sdata = sdata.rename_dims(rename_dims)
Expand Down
16 changes: 9 additions & 7 deletions pysatNASA/instruments/methods/omni.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ def time_shift_to_magnetic_poles(inst):

# Need to fill in Vx to get an estimate of what is going on.
inst['Vx'] = inst['Vx'].interpolate('nearest')
inst['Vx'] = inst['Vx'].fillna(method='backfill')
inst['Vx'] = inst['Vx'].fillna(method='pad')
inst['Vx'] = inst['Vx'].bfill()
inst['Vx'] = inst['Vx'].ffill()

inst['BSN_x'] = inst['BSN_x'].interpolate('nearest')
inst['BSN_x'] = inst['BSN_x'].fillna(method='backfill')
inst['BSN_x'] = inst['BSN_x'].fillna(method='pad')
inst['BSN_x'] = inst['BSN_x'].bfill()
inst['BSN_x'] = inst['BSN_x'].ffill()

# Make sure there are no gaps larger than a minute.
inst.data = inst.data.resample('1T').interpolate('time')
inst.data = inst.data.resample('1min').interpolate('time')

time_x = inst['BSN_x'] * 6371.2 / -inst['Vx']
idx, = np.where(np.isnan(time_x))
Expand Down Expand Up @@ -164,12 +164,14 @@ def calculate_imf_steadiness(inst, steady_window=15, min_window_frac=0.75,
if steady:
del_min = int((inst.data.index[i]
- inst.data.index[i - 1]).total_seconds() / 60.0)
if np.isnan(cv) or np.isnan(ca_std[i]) or del_min > sample_rate:
if np.any([np.isnan(cv),
np.isnan(ca_std.iloc[i]),
del_min > sample_rate]):
# Reset the steadiness flag if fill values are encountered, or
# if an entry is missing
steady = False

if cv <= max_bmag_cv and ca_std[i] <= max_clock_angle_std:
if cv <= max_bmag_cv and ca_std.iloc[i] <= max_clock_angle_std:
# Steadiness conditions have been met
if steady:
imf_steady[i] = imf_steady[i - 1]
Expand Down
4 changes: 2 additions & 2 deletions pysatNASA/tests/test_instruments.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ def test_load_cdflib(self, inst_dict):
target = 'Fake Data to be cleared'
test_inst.data = [target]
try:
test_inst.load(date=date, use_header=True, use_cdflib=True)
test_inst.load(date=date, use_cdflib=True)
except ValueError as verr:
# Check if instrument is failing due to strict time flag
if str(verr).find('Loaded data') > 0:
test_inst.strict_time_flag = False
with warnings.catch_warnings(record=True) as war:
test_inst.load(date=date, use_header=True)
test_inst.load(date=date)
assert len(war) >= 1
categories = [war[j].category for j in range(0, len(war))]
assert UserWarning in categories
Expand Down

0 comments on commit c9d6fde

Please sign in to comment.