-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #962 from nickssl/master
Refactored __init__.py file to dscovr
- Loading branch information
Showing
5 changed files
with
243 additions
and
462 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,310 +1,24 @@ | ||
from .load import load | ||
from functools import update_wrapper | ||
from pyspedas.dscovr.load import load | ||
from pyspedas.utilities.datasets import find_datasets | ||
|
||
|
||
def mag(trange=['2018-10-16', '2018-10-17'], | ||
datatype='h0', | ||
suffix='', | ||
get_support_data=False, | ||
varformat=None, | ||
varnames=[], | ||
downloadonly=False, | ||
notplot=False, | ||
no_update=False, | ||
time_clip=False, | ||
force_download=False): | ||
""" | ||
This function loads DSCOVR Fluxgate Magnetometer data | ||
Parameters | ||
---------- | ||
trange : list of str | ||
time range of interest [starttime, endtime] with the format | ||
'YYYY-MM-DD','YYYY-MM-DD'] or to specify more or less than a day | ||
['YYYY-MM-DD/hh:mm:ss','YYYY-MM-DD/hh:mm:ss'] | ||
datatype: str | ||
Data type; Valid options: | ||
'h0': 1-sec Definitive Data (default) | ||
suffix: str | ||
The tplot variable names will be given this suffix. By default, | ||
no suffix is added. | ||
get_support_data: bool | ||
Data with an attribute "VAR_TYPE" with a value of "support_data" | ||
will be loaded into tplot. By default, only loads in data with a | ||
"VAR_TYPE" attribute of "data". | ||
varformat: str | ||
The file variable formats to load into tplot. Wildcard character | ||
"*" is accepted. By default, all variables are loaded in. | ||
varnames: list of str | ||
List of variable names to load (if not specified, | ||
all data variables are loaded) | ||
downloadonly: bool | ||
Set this flag to download the CDF files, but not load them into | ||
tplot variables | ||
notplot: bool | ||
Return the data in hash tables instead of creating tplot variables | ||
no_update: bool | ||
If set, only load data from your local cache | ||
time_clip: bool | ||
Time clip the variables to exactly the range specified in the trange keyword | ||
force_download: bool | ||
Download file even if local version is more recent than server version | ||
Default: False | ||
Returns | ||
---------- | ||
List of tplot variables created. | ||
""" | ||
return load(instrument='mag', prefix='dsc_'+datatype+'_mag_', trange=trange, datatype=datatype, suffix=suffix, get_support_data=get_support_data, varformat=varformat, varnames=varnames, downloadonly=downloadonly, notplot=notplot, time_clip=time_clip, no_update=no_update, force_download=force_download) | ||
|
||
def fc(trange=['2018-10-16', '2018-10-17'], | ||
datatype='h1', | ||
suffix='', | ||
get_support_data=False, | ||
varformat=None, | ||
varnames=[], | ||
downloadonly=False, | ||
notplot=False, | ||
no_update=False, | ||
time_clip=False, | ||
force_download=False): | ||
""" | ||
This function loads DSCOVR Faraday Cup data | ||
Parameters | ||
---------- | ||
trange : list of str | ||
time range of interest [starttime, endtime] with the format | ||
'YYYY-MM-DD','YYYY-MM-DD'] or to specify more or less than a day | ||
['YYYY-MM-DD/hh:mm:ss','YYYY-MM-DD/hh:mm:ss'] | ||
datatype: str | ||
Data type; Valid options: | ||
'h1': 1-minute Isotropic Maxwellian parameters for solar wind protons (default) | ||
suffix: str | ||
The tplot variable names will be given this suffix. By default, | ||
no suffix is added. | ||
get_support_data: bool | ||
Data with an attribute "VAR_TYPE" with a value of "support_data" | ||
will be loaded into tplot. By default, only loads in data with a | ||
"VAR_TYPE" attribute of "data". | ||
varformat: str | ||
The file variable formats to load into tplot. Wildcard character | ||
"*" is accepted. By default, all variables are loaded in. | ||
varnames: list of str | ||
List of variable names to load (if not specified, | ||
all data variables are loaded) | ||
downloadonly: bool | ||
Set this flag to download the CDF files, but not load them into | ||
tplot variables | ||
notplot: bool | ||
Return the data in hash tables instead of creating tplot variables | ||
no_update: bool | ||
If set, only load data from your local cache | ||
time_clip: bool | ||
Time clip the variables to exactly the range specified in the trange keyword | ||
force_download: bool | ||
Download file even if local version is more recent than server version | ||
Default: False | ||
Returns | ||
---------- | ||
List of tplot variables created. | ||
""" | ||
return load(instrument='faraday_cup', prefix='dsc_'+datatype+'_fc_', trange=trange, datatype=datatype, suffix=suffix, get_support_data=get_support_data, varformat=varformat, varnames=varnames, downloadonly=downloadonly, notplot=notplot, time_clip=time_clip, no_update=no_update, force_download=force_download) | ||
|
||
def orb(trange=['2018-10-16', '2018-10-17'], | ||
datatype='orbit', | ||
suffix='', | ||
get_support_data=False, | ||
varformat=None, | ||
varnames=[], | ||
downloadonly=False, | ||
notplot=False, | ||
no_update=False, | ||
time_clip=False, | ||
force_download=False): | ||
""" | ||
This function loads DSCOVR Ephemeris data | ||
Parameters | ||
---------- | ||
trange : list of str | ||
time range of interest [starttime, endtime] with the format | ||
'YYYY-MM-DD','YYYY-MM-DD'] or to specify more or less than a day | ||
['YYYY-MM-DD/hh:mm:ss','YYYY-MM-DD/hh:mm:ss'] | ||
suffix: str | ||
The tplot variable names will be given this suffix. By default, | ||
no suffix is added. | ||
get_support_data: bool | ||
Data with an attribute "VAR_TYPE" with a value of "support_data" | ||
will be loaded into tplot. By default, only loads in data with a | ||
"VAR_TYPE" attribute of "data". | ||
varformat: str | ||
The file variable formats to load into tplot. Wildcard character | ||
"*" is accepted. By default, all variables are loaded in. | ||
varnames: list of str | ||
List of variable names to load (if not specified, | ||
all data variables are loaded) | ||
downloadonly: bool | ||
Set this flag to download the CDF files, but not load them into | ||
tplot variables | ||
notplot: bool | ||
Return the data in hash tables instead of creating tplot variables | ||
no_update: bool | ||
If set, only load data from your local cache | ||
time_clip: bool | ||
Time clip the variables to exactly the range specified in the trange keyword | ||
force_download: bool | ||
Download file even if local version is more recent than server version | ||
Default: False | ||
Returns | ||
---------- | ||
List of tplot variables created. | ||
""" | ||
return load(instrument='pre_or', prefix='dsc_orbit_', trange=trange, datatype=datatype, suffix=suffix, get_support_data=get_support_data, varformat=varformat, varnames=varnames, downloadonly=downloadonly, notplot=notplot, time_clip=time_clip, no_update=no_update, force_download=force_download) | ||
|
||
def att(trange=['2018-10-16', '2018-10-17'], | ||
datatype='orbit', | ||
suffix='', | ||
get_support_data=False, | ||
varformat=None, | ||
varnames=[], | ||
downloadonly=False, | ||
notplot=False, | ||
no_update=False, | ||
time_clip=False, | ||
force_download=False): | ||
""" | ||
This function loads DSCOVR Attitude data | ||
Parameters | ||
---------- | ||
trange : list of str | ||
time range of interest [starttime, endtime] with the format | ||
'YYYY-MM-DD','YYYY-MM-DD'] or to specify more or less than a day | ||
['YYYY-MM-DD/hh:mm:ss','YYYY-MM-DD/hh:mm:ss'] | ||
suffix: str | ||
The tplot variable names will be given this suffix. By default, | ||
no suffix is added. | ||
get_support_data: bool | ||
Data with an attribute "VAR_TYPE" with a value of "support_data" | ||
will be loaded into tplot. By default, only loads in data with a | ||
"VAR_TYPE" attribute of "data". | ||
varformat: str | ||
The file variable formats to load into tplot. Wildcard character | ||
"*" is accepted. By default, all variables are loaded in. | ||
varnames: list of str | ||
List of variable names to load (if not specified, | ||
all data variables are loaded) | ||
downloadonly: bool | ||
Set this flag to download the CDF files, but not load them into | ||
tplot variables | ||
notplot: bool | ||
Return the data in hash tables instead of creating tplot variables | ||
no_update: bool | ||
If set, only load data from your local cache | ||
time_clip: bool | ||
Time clip the variables to exactly the range specified in the trange keyword | ||
force_download: bool | ||
Download file even if local version is more recent than server version | ||
Default: False | ||
Returns | ||
---------- | ||
List of tplot variables created. | ||
""" | ||
return load(instrument='def_at', prefix='dsc_att_', trange=trange, datatype=datatype, suffix=suffix, get_support_data=get_support_data, varformat=varformat, varnames=varnames, downloadonly=downloadonly, notplot=notplot, time_clip=time_clip, no_update=no_update) | ||
|
||
def all(trange=['2018-10-16', '2018-10-17'], | ||
downloadonly=False, | ||
suffix='', | ||
no_update=False, | ||
time_clip=False, | ||
force_download=False): | ||
""" | ||
This function loads all DSCOVR data | ||
Parameters | ||
---------- | ||
trange : list of str | ||
time range of interest [starttime, endtime] with the format | ||
'YYYY-MM-DD','YYYY-MM-DD'] or to specify more or less than a day | ||
['YYYY-MM-DD/hh:mm:ss','YYYY-MM-DD/hh:mm:ss'] | ||
downloadonly: bool | ||
Set this flag to download the CDF files, but not load them into | ||
tplot variables | ||
no_update: bool | ||
If set, only load data from your local cache | ||
time_clip: bool | ||
Time clip the variables to exactly the range specified in the trange keyword | ||
force_download: bool | ||
Download file even if local version is more recent than server version | ||
Default: False | ||
Returns | ||
---------- | ||
List of tplot variables created. | ||
""" | ||
att_vars = att(trange=trange, downloadonly=downloadonly, time_clip=time_clip, no_update=no_update, force_download=force_download) | ||
orb_vars = orb(trange=trange, downloadonly=downloadonly, time_clip=time_clip, no_update=no_update, force_download=force_download) | ||
mag_vars = mag(trange=trange, downloadonly=downloadonly, time_clip=time_clip, no_update=no_update, force_download=force_download) | ||
fc_vars = fc(trange=trange, downloadonly=downloadonly, time_clip=time_clip, no_update=no_update, force_download=force_download) | ||
return att_vars + orb_vars + mag_vars + fc_vars | ||
|
||
|
||
def datasets(instrument=None, label=True): | ||
return find_datasets(mission='DSCOVR', instrument=instrument, label=label) | ||
from pyspedas.utilities.pyspedas_functools import better_partial | ||
|
||
|
||
# Define partial wrappers for other load routines, fixing the instrument parameter | ||
# 'better_partial' works better with PyCharm autocompletion than functools.partial | ||
# update_wrapper() is necessary for help() to show info for the wrapped function, | ||
# rather than the partial() object. | ||
|
||
mag = better_partial(load, instrument="mag") | ||
update_wrapper(mag, load) | ||
fc = better_partial(load, instrument="fc") | ||
update_wrapper(mag, load) | ||
orb = better_partial(load, instrument="orb") | ||
update_wrapper(orb, load) | ||
att = better_partial(load, instrument="att") | ||
update_wrapper(att, load) | ||
all = better_partial(load, instrument="all") | ||
update_wrapper(all, load) | ||
|
||
datasets = better_partial(find_datasets, mission="DSCOVR", label=True) | ||
update_wrapper(datasets, find_datasets) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.