Skip to content

Commit

Permalink
Merge pull request #128 from pysat/develop_lisird_fix
Browse files Browse the repository at this point in the history
Develop lisird fix
  • Loading branch information
aburrell authored Oct 24, 2023
2 parents 0d33b54 + cdb38a2 commit baaf37e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
* Added new test attributes for clean messages to the ACE instruments
* Maintenance
* Updated package documentation, yamls, and other supporting files
* Updated the LISIRD download routine to reflect new behaviour
* Changed F10.7 daily test day to ensure new pysat padding tests work

[0.0.10] - 2023-06-01
---------------------
Expand Down
19 changes: 13 additions & 6 deletions pysatSpaceWeather/instruments/methods/lisird.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,11 @@ def download(date_array, data_path, local_file_prefix, local_date_fmt,
raise IOError(''.join(['Gateway timeout when requesting ',
'file using command: ', url]))

if req.ok:
raw_dict = json.loads(req.text)[lisird_data_name]
# Load the dict if text was retrieved
json_dict = json.loads(req.text) if req.ok else {'': {}}

if lisird_data_name in json_dict.keys():
raw_dict = json_dict[lisird_data_name]
data = pds.DataFrame.from_dict(raw_dict['samples'])
if data.empty:
pysat.logger.warning("no data for {:}".format(dl_date))
Expand All @@ -176,8 +179,12 @@ def download(date_array, data_path, local_file_prefix, local_date_fmt,
# Create a local CSV file
data.to_csv(local_file, header=True)
else:
pysat.logger.info("".join(["Data not downloaded for ",
dl_date.strftime("%d %b %Y"),
", date may be out of range ",
"for the database."]))
if len(json_dict.keys()) == 1 and '' in json_dict.keys():
pysat.logger.info("".join(["Data not downloaded for ",
dl_date.strftime("%d %b %Y"),
", date may be out of range ",
"for the database."]))
else:
raise IOError(''.join(['Returned unexpectedly formatted ',
'data using command: ', url]))
return
2 changes: 1 addition & 1 deletion pysatSpaceWeather/instruments/sw_f107.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@

_test_dates = {'': {'historic': dt.datetime(2009, 1, 1),
'prelim': dt.datetime(2009, 1, 1),
'daily': tomorrow,
'daily': today,
'forecast': tomorrow,
'45day': tomorrow},
'obs': {'now': dt.datetime(2009, 1, 1)},
Expand Down
1 change: 1 addition & 0 deletions pysatSpaceWeather/tests/test_instruments.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class TestInstruments(clslib.InstLibTests):
----
All standard tests, setup, and teardown inherited from the core pysat
instrument test class.
"""


Expand Down

0 comments on commit baaf37e

Please sign in to comment.