Skip to content

Commit

Permalink
Merge pull request #184 from pysat/data_path_arg
Browse files Browse the repository at this point in the history
Data path arg
  • Loading branch information
JonathonMSmith committed Jun 8, 2023
2 parents 1850c78 + 16b8289 commit 9e0930c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
* Deprecations
* Deprecated jpl_gps instrtument module, moved roti instrument to igs_gps
* Maintenance
* Updated download functions to take data_path as an arg, not a kwarg
* Removed duplicate tests if pysatCDF not isntalled
* Removed pysatCDF tests on GitHub Actions workflows (see #167)
* Updated actions and templates based on pysatEcosystem docs
Expand Down
18 changes: 8 additions & 10 deletions pysatNASA/instruments/methods/cdaweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,8 @@ def load_xarray(fnames, tag='', inst_id='',


# TODO(#103): Include support to unzip / untar files after download.
def download(date_array, tag='', inst_id='', supported_tags=None,
remote_url='https://cdaweb.gsfc.nasa.gov', data_path=None):
def download(date_array, data_path, tag='', inst_id='', supported_tags=None,
remote_url='https://cdaweb.gsfc.nasa.gov'):
"""Download NASA CDAWeb data.
This routine is intended to be used by pysat instrument modules supporting
Expand All @@ -481,6 +481,8 @@ def download(date_array, tag='', inst_id='', supported_tags=None,
----------
date_array : array-like
Array of datetimes to download data for. Provided by pysat.
data_path : str
Path to data directory.
tag : str
Data product tag (default='')
inst_id : str
Expand All @@ -493,9 +495,6 @@ def download(date_array, tag='', inst_id='', supported_tags=None,
remote_url : str
Remote site to download data from
(default='https://cdaweb.gsfc.nasa.gov')
data_path : str or NoneType
Path to data directory. If None is specified, the value previously
set in Instrument.files.data_path is used. (default=None)
Examples
--------
Expand Down Expand Up @@ -570,8 +569,8 @@ def download(date_array, tag='', inst_id='', supported_tags=None,
return


def cdas_download(date_array, tag='', inst_id='', supported_tags=None,
data_path=None):
def cdas_download(date_array, data_path, tag='', inst_id='',
supported_tags=None):
"""Download NASA CDAWeb CDF data using cdasws.
This routine is intended to be used by pysat instrument modules supporting
Expand All @@ -581,6 +580,8 @@ def cdas_download(date_array, tag='', inst_id='', supported_tags=None,
----------
date_array : array-like
Array of datetimes to download data for. Provided by pysat.
data_path : str
Path to data directory.
tag : str
Data product tag (default='')
inst_id : str
Expand All @@ -590,9 +591,6 @@ def cdas_download(date_array, tag='', inst_id='', supported_tags=None,
a dict with 'remote_dir', 'fname'. Inteded to be pre-set with
functools.partial then assigned to new instrument code.
(default=None)
data_path : str or NoneType
Path to data directory. If None is specified, the value previously
set in Instrument.files.data_path is used. (default=None)
Note
----
Expand Down
2 changes: 2 additions & 0 deletions pysatNASA/tests/test_methods_cdaweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def setup_method(self):

self.download_tags = pysatNASA.instruments.timed_guvi.download_tags
self.kwargs = {'tag': None, 'inst_id': None}
self.saved_path = pysat.params['data_dirs']
return

def teardown_method(self):
Expand Down Expand Up @@ -61,6 +62,7 @@ def test_bad_kwarg_download(self, bad_key, bad_val, err_msg):
with pytest.raises(ValueError) as excinfo:
cdw.download(supported_tags=self.download_tags,
date_array=date_array,
data_path=self.saved_path,
tag=self.kwargs['tag'],
inst_id=self.kwargs['inst_id'])
assert str(excinfo.value).find(err_msg) >= 0
Expand Down

0 comments on commit 9e0930c

Please sign in to comment.