From 0a86a2fa5b0a8e538577ea2feb0880d024f8685b Mon Sep 17 00:00:00 2001 From: Nick H <34072991+nickssl@users.noreply.github.com> Date: Thu, 25 Jan 2024 18:31:00 -0800 Subject: [PATCH] Minor changes to docstrings. --- pyspedas/image/__init__.py | 754 +++++++++++++++++++------------------ pyspedas/image/config.py | 14 +- pyspedas/image/load.py | 184 +++++++-- 3 files changed, 534 insertions(+), 418 deletions(-) diff --git a/pyspedas/image/__init__.py b/pyspedas/image/__init__.py index 35131cac..130ccae6 100644 --- a/pyspedas/image/__init__.py +++ b/pyspedas/image/__init__.py @@ -2,426 +2,438 @@ from pyspedas.utilities.datasets import find_datasets -def lena(trange=['2004-11-5', '2004-11-6'], - datatype='k0', - suffix='', - get_support_data=False, - varformat=None, - varnames=[], - downloadonly=False, - notplot=False, - no_update=False, - time_clip=False): +def lena( + trange=["2004-11-5", "2004-11-6"], + datatype="k0", + suffix="", + get_support_data=False, + varformat=None, + varnames=[], + downloadonly=False, + notplot=False, + no_update=False, + time_clip=False, +): """ - This function loads IMAGE LENA data - + Loads IMAGE LENA 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: - - 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 + trange : list of str, optional + Time range of interest 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']. + Defaults to ['2004-11-5', '2004-11-6']. + datatype : str, optional + Data type. Defaults to 'k0'. + suffix : str, optional + The tplot variable names will be given this suffix. Defaults to ''. + get_support_data : bool, optional + 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". Defaults to False. + varformat : str, optional + The file variable formats to load into tplot. Wildcard character "*" is accepted. + By default, all variables are loaded in. Defaults to None. + varnames : list of str, optional + List of variable names to load. If not specified, all data variables are loaded. Defaults to []. + downloadonly : bool, optional + Set this flag to download the CDF files, but not load them into tplot variables. Defaults to False. + notplot : bool, optional + Return the data in hash tables instead of creating tplot variables. Defaults to False. + no_update : bool, optional + If set, only load data from your local cache. Defaults to False. + time_clip : bool, optional + Time clip the variables to exactly the range specified in the trange keyword. Defaults to False. Returns - ---------- + ------- + list List of tplot variables created. - """ - return load(instrument='lena', 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 mena(trange=['2004-11-5', '2004-11-6'], - datatype='k0', - suffix='', - get_support_data=False, - varformat=None, - varnames=[], - downloadonly=False, - notplot=False, - no_update=False, - time_clip=False): + return load( + instrument="lena", + 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 mena( + trange=["2004-11-5", "2004-11-6"], + datatype="k0", + suffix="", + get_support_data=False, + varformat=None, + varnames=[], + downloadonly=False, + notplot=False, + no_update=False, + time_clip=False, +): """ - This function loads IMAGE MENA data - + Loads IMAGE MENA 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: - - 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 + trange : list of str, optional + Time range of interest 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']. + Defaults to ['2004-11-5', '2004-11-6']. + datatype : str, optional + Data type. Defaults to 'k0'. + suffix : str, optional + The tplot variable names will be given this suffix. Defaults to ''. + get_support_data : bool, optional + 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". Defaults to False. + varformat : str, optional + The file variable formats to load into tplot. Wildcard character "*" is accepted. + By default, all variables are loaded in. Defaults to None. + varnames : list of str, optional + List of variable names to load. If not specified, all data variables are loaded. Defaults to []. + downloadonly : bool, optional + Set this flag to download the CDF files, but not load them into tplot variables. Defaults to False. + notplot : bool, optional + Return the data in hash tables instead of creating tplot variables. Defaults to False. + no_update : bool, optional + If set, only load data from your local cache. Defaults to False. + time_clip : bool, optional + Time clip the variables to exactly the range specified in the trange keyword. Defaults to False. Returns - ---------- + ------- + list List of tplot variables created. - """ - return load(instrument='mena', 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 hena(trange=['2004-11-5', '2004-11-6'], - datatype='k0', - suffix='', - get_support_data=False, - varformat=None, - varnames=[], - downloadonly=False, - notplot=False, - no_update=False, - time_clip=False): + return load( + instrument="mena", + 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 hena( + trange=["2004-11-5", "2004-11-6"], + datatype="k0", + suffix="", + get_support_data=False, + varformat=None, + varnames=[], + downloadonly=False, + notplot=False, + no_update=False, + time_clip=False, +): """ - This function loads IMAGE HENA data - + Loads IMAGE HENA 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: - - 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 + trange : list of str, optional + Time range of interest 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']. + Defaults to ['2004-11-5', '2004-11-6']. + datatype : str, optional + Data type. Defaults to 'k0'. + suffix : str, optional + The tplot variable names will be given this suffix. Defaults to ''. + get_support_data : bool, optional + 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". Defaults to False. + varformat : str, optional + The file variable formats to load into tplot. Wildcard character "*" is accepted. + By default, all variables are loaded in. Defaults to None. + varnames : list of str, optional + List of variable names to load. If not specified, all data variables are loaded. Defaults to []. + downloadonly : bool, optional + Set this flag to download the CDF files, but not load them into tplot variables. Defaults to False. + notplot : bool, optional + Return the data in hash tables instead of creating tplot variables. Defaults to False. + no_update : bool, optional + If set, only load data from your local cache. Defaults to False. + time_clip : bool, optional + Time clip the variables to exactly the range specified in the trange keyword. Defaults to False. Returns - ---------- + ------- + list List of tplot variables created. - """ - return load(instrument='hena', 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 rpi(trange=['2004-11-5', '2004-11-6'], - datatype='k0', - suffix='', - get_support_data=False, - varformat=None, - varnames=[], - downloadonly=False, - notplot=False, - no_update=False, - time_clip=False): + return load( + instrument="hena", + 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 rpi( + trange=["2004-11-5", "2004-11-6"], + datatype="k0", + suffix="", + get_support_data=False, + varformat=None, + varnames=[], + downloadonly=False, + notplot=False, + no_update=False, + time_clip=False, +): """ - This function loads IMAGE RPI data - + Loads IMAGE RPI 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: - - 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 + trange : list of str, optional + Time range of interest 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']. + Defaults to ['2004-11-5', '2004-11-6']. + datatype : str, optional + Data type. Defaults to 'k0'. + suffix : str, optional + The tplot variable names will be given this suffix. Defaults to ''. + get_support_data : bool, optional + 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". Defaults to False. + varformat : str, optional + The file variable formats to load into tplot. Wildcard character "*" is accepted. + By default, all variables are loaded in. Defaults to None. + varnames : list of str, optional + List of variable names to load. If not specified, all data variables are loaded. Defaults to []. + downloadonly : bool, optional + Set this flag to download the CDF files, but not load them into tplot variables. Defaults to False. + notplot : bool, optional + Return the data in hash tables instead of creating tplot variables. Defaults to False. + no_update : bool, optional + If set, only load data from your local cache. Defaults to False. + time_clip : bool, optional + Time clip the variables to exactly the range specified in the trange keyword. Defaults to False. Returns - ---------- + ------- + list List of tplot variables created. - """ - return load(instrument='rpi', 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 euv(trange=['2004-11-5', '2004-11-6'], - datatype='k0', - suffix='', - get_support_data=False, - varformat=None, - varnames=[], - downloadonly=False, - notplot=False, - no_update=False, - time_clip=False): + return load( + instrument="rpi", + 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 euv( + trange=["2004-11-5", "2004-11-6"], + datatype="k0", + suffix="", + get_support_data=False, + varformat=None, + varnames=[], + downloadonly=False, + notplot=False, + no_update=False, + time_clip=False, +): """ - This function loads IMAGE EUV data - + Loads IMAGE EUV 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: - - 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 + trange : list of str, optional + Time range of interest 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']. + Defaults to ['2004-11-5', '2004-11-6']. + datatype : str, optional + Data type. Defaults to 'k0'. + suffix : str, optional + The tplot variable names will be given this suffix. Defaults to ''. + get_support_data : bool, optional + 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". Defaults to False. + varformat : str, optional + The file variable formats to load into tplot. Wildcard character "*" is accepted. + By default, all variables are loaded in. Defaults to None. + varnames : list of str, optional + List of variable names to load. If not specified, all data variables are loaded. Defaults to []. + downloadonly : bool, optional + Set this flag to download the CDF files, but not load them into tplot variables. Defaults to False. + notplot : bool, optional + Return the data in hash tables instead of creating tplot variables. Defaults to False. + no_update : bool, optional + If set, only load data from your local cache. Defaults to False. + time_clip : bool, optional + Time clip the variables to exactly the range specified in the trange keyword. Defaults to False. Returns - ---------- + ------- + list List of tplot variables created. - """ - return load(instrument='euv', 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 fuv(trange=['2004-11-5', '2004-11-6'], - datatype='k0', - suffix='', - get_support_data=False, - varformat=None, - varnames=[], - downloadonly=False, - notplot=False, - no_update=False, - time_clip=False): + return load( + instrument="euv", + 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 fuv( + trange=["2004-11-5", "2004-11-6"], + datatype="k0", + suffix="", + get_support_data=False, + varformat=None, + varnames=[], + downloadonly=False, + notplot=False, + no_update=False, + time_clip=False, +): """ - This function loads IMAGE FUV data - + Loads IMAGE FUV 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: - - 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 + trange : list of str, optional + Time range of interest 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']. + Defaults to ['2004-11-5', '2004-11-6']. + datatype : str, optional + Data type. Defaults to 'k0'. + suffix : str, optional + The tplot variable names will be given this suffix. Defaults to ''. + get_support_data : bool, optional + 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". Defaults to False. + varformat : str, optional + The file variable formats to load into tplot. Wildcard character "*" is accepted. + By default, all variables are loaded in. Defaults to None. + varnames : list of str, optional + List of variable names to load. If not specified, all data variables are loaded. Defaults to []. + downloadonly : bool, optional + Set this flag to download the CDF files, but not load them into tplot variables. Defaults to False. + notplot : bool, optional + Return the data in hash tables instead of creating tplot variables. Defaults to False. + no_update : bool, optional + If set, only load data from your local cache. Defaults to False. + time_clip : bool, optional + Time clip the variables to exactly the range specified in the trange keyword. Defaults to False. Returns - ---------- + ------- + list List of tplot variables created. - """ - return load(instrument='fuv', 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 orbit(trange=['2004-11-5', '2004-11-6'], - datatype='def_or', - suffix='', - get_support_data=False, - varformat=None, - varnames=[], - downloadonly=False, - notplot=False, - no_update=False, - time_clip=False): + return load( + instrument="fuv", + 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 orbit( + trange=["2004-11-5", "2004-11-6"], + datatype="def_or", + suffix="", + get_support_data=False, + varformat=None, + varnames=[], + downloadonly=False, + notplot=False, + no_update=False, + time_clip=False, +): """ - This function loads IMAGE orbit data - + Loads IMAGE orbit 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: - - 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 + trange : list of str + Time range of interest 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 are not specified in the function signature. + suffix : str, optional + The tplot variable names will be given this suffix. By default, no suffix is added. + get_support_data : bool, optional + 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, optional + The file variable formats to load into tplot. Wildcard character "*" is accepted. + By default, all variables are loaded in. + varnames : list of str, optional + List of variable names to load. If not specified, all data variables are loaded. + downloadonly : bool, optional + Set this flag to download the CDF files, but not load them into tplot variables. + notplot : bool, optional + Return the data in hash tables instead of creating tplot variables. + no_update : bool, optional + If set, only load data from your local cache. + time_clip : bool, optional + Time clip the variables to exactly the range specified in the trange keyword. Returns - ---------- + ------- + list List of tplot variables created. - """ - return load(instrument='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) + return load( + instrument="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, + ) def datasets(instrument=None, label=True): - return find_datasets(mission='IMAGE', instrument=instrument, label=label) + return find_datasets(mission="IMAGE", instrument=instrument, label=label) diff --git a/pyspedas/image/config.py b/pyspedas/image/config.py index 4faf1fd5..a5a395c0 100644 --- a/pyspedas/image/config.py +++ b/pyspedas/image/config.py @@ -1,11 +1,13 @@ import os -CONFIG = {'local_data_dir': 'image_data/', - 'remote_data_dir': 'https://spdf.gsfc.nasa.gov/pub/data/image/'} +CONFIG = { + "local_data_dir": "image_data/", + "remote_data_dir": "https://spdf.gsfc.nasa.gov/pub/data/image/", +} # override local data directory with environment variables -if os.environ.get('SPEDAS_DATA_DIR'): - CONFIG['local_data_dir'] = os.sep.join([os.environ['SPEDAS_DATA_DIR'], 'image']) +if os.environ.get("SPEDAS_DATA_DIR"): + CONFIG["local_data_dir"] = os.sep.join([os.environ["SPEDAS_DATA_DIR"], "image"]) -if os.environ.get('IMAGE_DATA_DIR'): - CONFIG['local_data_dir'] = os.environ['IMAGE_DATA_DIR'] \ No newline at end of file +if os.environ.get("IMAGE_DATA_DIR"): + CONFIG["local_data_dir"] = os.environ["IMAGE_DATA_DIR"] diff --git a/pyspedas/image/load.py b/pyspedas/image/load.py index 56765342..c7dd9e7d 100644 --- a/pyspedas/image/load.py +++ b/pyspedas/image/load.py @@ -5,53 +5,148 @@ from .config import CONFIG -def load(trange=['2004-11-5', '2004-11-6'], - instrument='lena', - datatype='k0', - suffix='', - get_support_data=False, - varformat=None, - varnames=[], - downloadonly=False, - notplot=False, - no_update=False, - time_clip=False): + +def load( + trange=["2004-11-5", "2004-11-6"], + instrument="lena", + datatype="k0", + suffix="", + get_support_data=False, + varformat=None, + varnames=[], + downloadonly=False, + notplot=False, + no_update=False, + time_clip=False, +): """ - This function loads IMAGE data; this function is not meant - to be called directly; instead, see the wrappers: - pyspedas.image.lena - pyspedas.image.mena - pyspedas.image.hena - pyspedas.image.rpi - pyspedas.image.euv - pyspedas.image.fuv - + Load IMAGE data. + + Parameters + ---------- + trange : list of str, optional + Time range for the data in the format ['start_date', 'end_date']. + Defaults to ['2004-11-5', '2004-11-6']. + instrument : str, optional + Instrument name. Defaults to 'lena'. + datatype : str, optional + Data type. Defaults to 'k0'. + suffix : str, optional + Suffix to be added to the variable names. Defaults to ''. + get_support_data : bool, optional + Flag indicating whether to retrieve support data. Defaults to False. + varformat : str, optional + Variable format. Defaults to None. + varnames : list of str, optional + List of variable names to load. Defaults to []. + downloadonly : bool, optional + Flag indicating whether to only download the files without loading the data. Defaults to False. + notplot : bool, optional + Flag indicating whether to return the loaded data without plotting. Defaults to False. + no_update : bool, optional + Flag indicating whether to skip updating the data files. Defaults to False. + time_clip : bool, optional + Flag indicating whether to clip the loaded data to the specified time range. Defaults to False. + + Returns + ------- + list or dict + If `downloadonly` is True, returns a list of downloaded file names. + If `notplot` is True, returns a dictionary of loaded data variables. + Otherwise, returns a list of loaded data variables. """ - if instrument == 'lena': - pathformat = instrument+'/'+instrument+'_'+datatype+'/%Y/im_'+datatype+'_'+instrument+'_%Y%m%d_v??.cdf' - elif instrument == 'mena': - pathformat = instrument+'/'+instrument+'_'+datatype+'/%Y/im_'+datatype+'_'+instrument+'_%Y%m%d_v??.cdf' - elif instrument == 'hena': - pathformat = instrument+'/'+instrument+'_'+datatype+'/%Y/im_'+datatype+'_'+instrument+'_%Y%m%d_v??.cdf' - elif instrument == 'rpi': - pathformat = instrument+'/'+instrument+'_'+datatype+'/%Y/im_'+datatype+'_'+instrument+'_%Y%m%d_v??.cdf' - elif instrument == 'euv': - pathformat = instrument+'/'+instrument+'_'+datatype+'/%Y/im_'+datatype+'_'+instrument+'_%Y%m%d_v??.cdf' - elif instrument == 'fuv': - pathformat = instrument+'/wic_'+datatype+'/%Y/im_'+datatype+'_wic_%Y%m%d_v??.cdf' - elif instrument == 'orbit': - if datatype == 'def_or': - pathformat = instrument+'/def_or/%Y/im_or_def_%Y%m%d_v??.cdf' - elif datatype == 'pre_or': - pathformat = instrument+'/pre_or/%Y/im_or_pre_%Y%m%d_v??.cdf' + if instrument == "lena": + pathformat = ( + instrument + + "/" + + instrument + + "_" + + datatype + + "/%Y/im_" + + datatype + + "_" + + instrument + + "_%Y%m%d_v??.cdf" + ) + elif instrument == "mena": + pathformat = ( + instrument + + "/" + + instrument + + "_" + + datatype + + "/%Y/im_" + + datatype + + "_" + + instrument + + "_%Y%m%d_v??.cdf" + ) + elif instrument == "hena": + pathformat = ( + instrument + + "/" + + instrument + + "_" + + datatype + + "/%Y/im_" + + datatype + + "_" + + instrument + + "_%Y%m%d_v??.cdf" + ) + elif instrument == "rpi": + pathformat = ( + instrument + + "/" + + instrument + + "_" + + datatype + + "/%Y/im_" + + datatype + + "_" + + instrument + + "_%Y%m%d_v??.cdf" + ) + elif instrument == "euv": + pathformat = ( + instrument + + "/" + + instrument + + "_" + + datatype + + "/%Y/im_" + + datatype + + "_" + + instrument + + "_%Y%m%d_v??.cdf" + ) + elif instrument == "fuv": + pathformat = ( + instrument + + "/wic_" + + datatype + + "/%Y/im_" + + datatype + + "_wic_%Y%m%d_v??.cdf" + ) + elif instrument == "orbit": + if datatype == "def_or": + pathformat = instrument + "/def_or/%Y/im_or_def_%Y%m%d_v??.cdf" + elif datatype == "pre_or": + pathformat = instrument + "/pre_or/%Y/im_or_pre_%Y%m%d_v??.cdf" # find the full remote path names using the trange remote_names = dailynames(file_format=pathformat, trange=trange) out_files = [] - files = download(remote_file=remote_names, remote_path=CONFIG['remote_data_dir'], local_path=CONFIG['local_data_dir'], no_download=no_update) + files = download( + remote_file=remote_names, + remote_path=CONFIG["remote_data_dir"], + local_path=CONFIG["local_data_dir"], + no_download=no_update, + ) if files is not None: for file in files: out_files.append(file) @@ -61,13 +156,20 @@ def load(trange=['2004-11-5', '2004-11-6'], if downloadonly: return out_files - tvars = cdf_to_tplot(out_files, suffix=suffix, get_support_data=get_support_data, varformat=varformat, varnames=varnames, notplot=notplot) - + tvars = cdf_to_tplot( + out_files, + suffix=suffix, + get_support_data=get_support_data, + varformat=varformat, + varnames=varnames, + notplot=notplot, + ) + if notplot: return tvars if time_clip: for new_var in tvars: - tclip(new_var, trange[0], trange[1], suffix='') + tclip(new_var, trange[0], trange[1], suffix="") return tvars