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

Remote list break fix #71

Merged
merged 22 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from 16 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).
- Moved warning for no cleaning of JRO ISR data to preprocess
- Standardized the Instrument method kwarg defaults
- Added 'site' tag to the GNSS TEC Instrument
- Added support for varied use of `two_digit_year_break` to
`methods.general.list_remote_files`
- Implemented `two_digit_year_break` support for `vtec` GNSS TEC Instrument
- Documentation
- Added examples for JRO and GNSS data
- Improved the docstring style
Expand Down
59 changes: 52 additions & 7 deletions pysatMadrigal/instruments/gnss_tec.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"""

import datetime as dt
import functools
import numpy as np

from pysat import logger
Expand Down Expand Up @@ -115,12 +114,6 @@ def clean(self):
#
# Use the default Madrigal methods

# Support listing files currently available on remote server (Madrigal)
list_remote_files = functools.partial(general.list_remote_files,
supported_tags=remote_tags,
inst_code=madrigal_inst_code,
kindats=madrigal_tag)


def list_files(tag, inst_id, data_path=None, format_str=None,
file_cadence=dt.timedelta(days=1), delimiter=None,
Expand Down Expand Up @@ -290,3 +283,55 @@ def load(fnames, tag='', inst_id=''):
meta.labels.max_val: min_lon + 360.0}

return data, meta


def list_remote_files(tag, inst_id, start=dt.datetime(1900, 1, 1),
rstoneback marked this conversation as resolved.
Show resolved Hide resolved
stop=dt.datetime.utcnow(), user=None, password=None):
"""Return a Pandas Series of every file for chosen remote data.

Parameters
----------
tag : str
Denotes type of file to load. This input is nominally provided
by pysat itself.
inst_id : str
Specifies the satellite or instrument ID. This input is nominally
provided by pysat itself.
start : dt.datetime or NoneType
Starting time for file list. If None, replaced with default.
(default=01-01-1900)
rstoneback marked this conversation as resolved.
Show resolved Hide resolved
stop : dt.datetime or NoneType
Ending time for the file list. If None, replaced with default.
(default=time of run)
user : str or NoneType
Username to be passed along to resource with relevant data.
(default=None)
password : str or NoneType
User password to be passed along to resource with relevant data.
(default=None)

Returns
-------
files : pds.Series
A series of filenames, see `pysat.utils.files.process_parsed_filenames`
for more information.

See Also
--------
pysatMadrigal.instruments.methods.general.list_remote_files

"""

if tag == 'site':
rstoneback marked this conversation as resolved.
Show resolved Hide resolved
files = general.list_remote_files(
tag, inst_id, supported_tags=remote_tags,
inst_code=madrigal_inst_code, kindats=madrigal_tag, start=start,
stop=stop, user=user, password=password)

elif tag == 'vtec':
files = general.list_remote_files(
tag, inst_id, supported_tags=remote_tags,
inst_code=madrigal_inst_code, kindats=madrigal_tag, start=start,
stop=stop, user=user, password=password, two_digit_year_break=99)

return files
21 changes: 15 additions & 6 deletions pysatMadrigal/instruments/methods/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ def list_remote_files(tag, inst_id, inst_code=None, kindats=None, user=None,
Path to directory to download data to. (default=None)
user : str or NoneType
User string input used for download. Provided by user and passed via
pysat. If an account is required for dowloads this routine here must
pysat. If an account is required for downloads this routine here must
error if user not supplied. (default=None)
password : str or NoneType
Password for data download. (default=None)
Expand All @@ -639,14 +639,16 @@ def list_remote_files(tag, inst_id, inst_code=None, kindats=None, user=None,
where the values file format template strings. (default=None)
url : str
URL for Madrigal site (default='http://cedar.openmadrigal.org')
two_digit_year_break : int
two_digit_year_break : int or NoneType
If filenames only store two digits for the year, then
'1900' will be added for years >= two_digit_year_break
and '2000' will be added for years < two_digit_year_break.
rstoneback marked this conversation as resolved.
Show resolved Hide resolved
start : dt.datetime
Starting time for file list (defaults to 01-01-1900)
stop : dt.datetime
Ending time for the file list (defaults to time of run)
start : dt.datetime or NoneType
Starting time for file list. If None, replaces with default.
(default=01-01-1900)
stop : dt.datetime or NoneType
Ending time for the file list. If None, replaces with default.
(default=time of run)
rstoneback marked this conversation as resolved.
Show resolved Hide resolved

Returns
-------
Expand Down Expand Up @@ -695,6 +697,13 @@ def list_remote_files(tag, inst_id, inst_code=None, kindats=None, user=None,
format_str = supported_tags[inst_id][tag]
kindat = kindats[inst_id][tag]

# Note that default of `pysat.Instrument.remote_file_list` for start and
# stop is None. Setting defaults needed for Madrigal.
if start is None:
start = dt.datetime(1900, 1, 1)
if stop is None:
stop = dt.datetime.utcnow()

rstoneback marked this conversation as resolved.
Show resolved Hide resolved
# Retrieve remote file experiment list
files = get_remote_filenames(inst_code=inst_code, kindat=kindat, user=user,
password=password, url=url, start=start,
Expand Down