From 36e7ab41617e35a65ad8280d844606046cd43fca Mon Sep 17 00:00:00 2001 From: Nick H <34072991+nickssl@users.noreply.github.com> Date: Tue, 23 Jan 2024 11:50:58 -0800 Subject: [PATCH] Added info to README. Minor format changes. --- pyspedas/goes/README.md | 47 +++- pyspedas/goes/__init__.py | 447 +++++++++++++++++++++++------------- pyspedas/goes/config.py | 15 +- pyspedas/goes/load.py | 351 ++++++++++++++++++---------- pyspedas/goes/load_orbit.py | 62 +++-- 5 files changed, 611 insertions(+), 311 deletions(-) diff --git a/pyspedas/goes/README.md b/pyspedas/goes/README.md index 6a2a7948..550afa6f 100644 --- a/pyspedas/goes/README.md +++ b/pyspedas/goes/README.md @@ -2,8 +2,25 @@ ## Geostationary Operational Environmental Satellite (GOES) The routines in this module can be used to load data from the GOES mission. +The load routine works for both the older GOES probes (GOES-8 to GOES-15) and the newer GOES-R probes (GOES-16 and later). +However, the datasets are different for probes 8-15 and for probes 16+. + + + ### Instruments -- Magnetometer (FGM) +For GOES 8-15: fgm, eps, epead, maged, magpd, hepad, xrs + +For GOES-R 16-18: euvs, xrs, mag, mpsh, sgps + + +### Datatypes + +Depends on the probe and the instrument. It is usually the instrument resolution. + +For GOES-8 to 15, valid values: hi, low, full, avg, 1min, 5min + +For GOES-R (16 and later), valid values: hi, low, full, avg + ### Examples Get started by importing pyspedas and tplot; these are required to load and plot the data: @@ -13,11 +30,35 @@ import pyspedas from pytplot import tplot ``` -#### Magnetometer (FGM) +#### For older GOES probes (up to GOES-15) + +Example for Magnetometer data (FGM): ```python mag_vars = pyspedas.goes.fgm(trange=['2013-11-5', '2013-11-6'], datatype='512ms') - +print(mag_vars) tplot(['BX_1', 'BY_1', 'BZ_1']) ``` +#### For GOES-R probes (GOES-16 or newer) + +Example for Magnetometer data (mag): + +```python +mag_goes18 = pyspedas.goes.load(trange=['2023-01-01', '2023-01-02'], probe='18', instrument='mag') +print(mag_goes18) +tplot(['b_gsm', 'b_total']) +``` + + +### Further Information + +For more information on GOES-R, see: +https://www.ngdc.noaa.gov/stp/satellite/goes-r.html + +For NOAA Space Weather Prediction Center, see: +https://www.swpc.noaa.gov/ + +For GOES summary plots, see: +https://themis.ssl.berkeley.edu/summary.php?year=2024&month=01&day=01&hour=0024&sumType=goes&type=goes18 + diff --git a/pyspedas/goes/__init__.py b/pyspedas/goes/__init__.py index 08850a56..cddb102b 100644 --- a/pyspedas/goes/__init__.py +++ b/pyspedas/goes/__init__.py @@ -2,17 +2,19 @@ from .load_orbit import load_orbit -def orbit(trange=['2013-11-5', '2013-11-6'], - probe='15', - prefix='', - suffix='', - downloadonly=False, - no_update=False, - notplot=False, - get_support_data=False, - varformat=None, - varnames=[], - time_clip=True): +def orbit( + trange=["2013-11-5", "2013-11-6"], + probe="15", + prefix="", + suffix="", + downloadonly=False, + no_update=False, + notplot=False, + get_support_data=False, + varformat=None, + varnames=[], + time_clip=True, +): """ This function loads GOES orbit data (probes 8-18) @@ -51,23 +53,35 @@ def orbit(trange=['2013-11-5', '2013-11-6'], Time clip the variables to exactly the range specified in the trange keyword Returns - ---------- + ------- List of tplot variables created. Or list of filenames downloaded. """ - return load_orbit(trange=trange, probe=probe, varnames=varnames, varformat=varformat, - prefix=prefix, suffix=suffix, downloadonly=downloadonly, - no_update=no_update, time_clip=time_clip, notplot=notplot, get_support_data=get_support_data) - - -def fgm(trange=['2013-11-5', '2013-11-6'], - probe='15', - datatype='1min', - prefix='', - suffix='', - downloadonly=False, - no_update=False, - time_clip=False): + return load_orbit( + trange=trange, + probe=probe, + varnames=varnames, + varformat=varformat, + prefix=prefix, + suffix=suffix, + downloadonly=downloadonly, + no_update=no_update, + time_clip=time_clip, + notplot=notplot, + get_support_data=get_support_data, + ) + + +def fgm( + trange=["2013-11-5", "2013-11-6"], + probe="15", + datatype="1min", + prefix="", + suffix="", + downloadonly=False, + no_update=False, + time_clip=False, +): """ This function loads data from the GOES Magnetometer (probes 8-15) @@ -104,22 +118,33 @@ def fgm(trange=['2013-11-5', '2013-11-6'], Time clip the variables to exactly the range specified in the trange keyword Returns - ---------- + ------- List of tplot variables created. Or list of filenames downloaded. """ - return load(instrument='fgm', trange=trange, probe=probe, datatype=datatype, prefix=prefix, suffix=suffix, downloadonly=downloadonly, - time_clip=time_clip, no_update=no_update) - - -def eps(trange=['2013-11-5', '2013-11-6'], - probe='12', - datatype='1min', - prefix='', - suffix='', - downloadonly=False, - no_update=False, - time_clip=False): + return load( + instrument="fgm", + trange=trange, + probe=probe, + datatype=datatype, + prefix=prefix, + suffix=suffix, + downloadonly=downloadonly, + time_clip=time_clip, + no_update=no_update, + ) + + +def eps( + trange=["2013-11-5", "2013-11-6"], + probe="12", + datatype="1min", + prefix="", + suffix="", + downloadonly=False, + no_update=False, + time_clip=False, +): """ This function loads data from the GOES energetic particle sensor (probes 8-15) @@ -156,22 +181,33 @@ def eps(trange=['2013-11-5', '2013-11-6'], Time clip the variables to exactly the range specified in the trange keyword Returns - ---------- + ------- List of tplot variables created. Or list of filenames downloaded. """ - return load(instrument='eps', trange=trange, probe=probe, datatype=datatype, prefix=prefix, suffix=suffix, - downloadonly=downloadonly, time_clip=time_clip, no_update=no_update) - - -def epead(trange=['2013-11-5', '2013-11-6'], - probe='15', - datatype='1min', - prefix='', - suffix='', - downloadonly=False, - no_update=False, - time_clip=False): + return load( + instrument="eps", + trange=trange, + probe=probe, + datatype=datatype, + prefix=prefix, + suffix=suffix, + downloadonly=downloadonly, + time_clip=time_clip, + no_update=no_update, + ) + + +def epead( + trange=["2013-11-5", "2013-11-6"], + probe="15", + datatype="1min", + prefix="", + suffix="", + downloadonly=False, + no_update=False, + time_clip=False, +): """ This function loads data from the GOES Electron, Proton, Alpha Detector (probes 8-15) @@ -208,22 +244,33 @@ def epead(trange=['2013-11-5', '2013-11-6'], Time clip the variables to exactly the range specified in the trange keyword Returns - ---------- + ------- List of tplot variables created. Or list of filenames downloaded. """ - return load(instrument='epead', trange=trange, probe=probe, datatype=datatype, prefix=prefix, suffix=suffix, - downloadonly=downloadonly, time_clip=time_clip, no_update=no_update) - - -def maged(trange=['2013-11-5', '2013-11-6'], - probe='15', - datatype='1min', - prefix='', - suffix='', - downloadonly=False, - no_update=False, - time_clip=False): + return load( + instrument="epead", + trange=trange, + probe=probe, + datatype=datatype, + prefix=prefix, + suffix=suffix, + downloadonly=downloadonly, + time_clip=time_clip, + no_update=no_update, + ) + + +def maged( + trange=["2013-11-5", "2013-11-6"], + probe="15", + datatype="1min", + prefix="", + suffix="", + downloadonly=False, + no_update=False, + time_clip=False, +): """ This function loads data from the GOES Magnetospheric Electron Detector (probes 8-15) @@ -260,22 +307,33 @@ def maged(trange=['2013-11-5', '2013-11-6'], Time clip the variables to exactly the range specified in the trange keyword Returns - ---------- + ------- List of tplot variables created. Or list of filenames downloaded. """ - return load(instrument='maged', trange=trange, probe=probe, datatype=datatype, prefix=prefix, suffix=suffix, - downloadonly=downloadonly, time_clip=time_clip, no_update=no_update) - - -def magpd(trange=['2013-11-5', '2013-11-6'], - probe='15', - datatype='1min', - prefix='', - suffix='', - downloadonly=False, - no_update=False, - time_clip=False): + return load( + instrument="maged", + trange=trange, + probe=probe, + datatype=datatype, + prefix=prefix, + suffix=suffix, + downloadonly=downloadonly, + time_clip=time_clip, + no_update=no_update, + ) + + +def magpd( + trange=["2013-11-5", "2013-11-6"], + probe="15", + datatype="1min", + prefix="", + suffix="", + downloadonly=False, + no_update=False, + time_clip=False, +): """ This function loads data from the GOES Magnetospheric Proton Detector (probes 8-15) @@ -312,22 +370,33 @@ def magpd(trange=['2013-11-5', '2013-11-6'], Time clip the variables to exactly the range specified in the trange keyword Returns - ---------- + ------- List of tplot variables created. Or list of filenames downloaded. """ - return load(instrument='magpd', trange=trange, probe=probe, datatype=datatype, prefix=prefix, suffix=suffix, - downloadonly=downloadonly, time_clip=time_clip, no_update=no_update) - - -def hepad(trange=['2013-11-5', '2013-11-6'], - probe='15', - datatype='1min', - prefix='', - suffix='', - downloadonly=False, - no_update=False, - time_clip=False): + return load( + instrument="magpd", + trange=trange, + probe=probe, + datatype=datatype, + prefix=prefix, + suffix=suffix, + downloadonly=downloadonly, + time_clip=time_clip, + no_update=no_update, + ) + + +def hepad( + trange=["2013-11-5", "2013-11-6"], + probe="15", + datatype="1min", + prefix="", + suffix="", + downloadonly=False, + no_update=False, + time_clip=False, +): """ This function loads data from the GOES High energy Proton and Alpha Detector (probes 8-15) @@ -364,22 +433,33 @@ def hepad(trange=['2013-11-5', '2013-11-6'], Time clip the variables to exactly the range specified in the trange keyword Returns - ---------- + ------- List of tplot variables created. Or list of filenames downloaded. """ - return load(instrument='hepad', trange=trange, probe=probe, datatype=datatype, prefix=prefix, suffix=suffix, - downloadonly=downloadonly, time_clip=time_clip, no_update=no_update) - - -def xrs(trange=['2013-11-5', '2013-11-6'], - probe='15', - datatype='1min', - prefix='', - suffix='', - downloadonly=False, - no_update=False, - time_clip=False): + return load( + instrument="hepad", + trange=trange, + probe=probe, + datatype=datatype, + prefix=prefix, + suffix=suffix, + downloadonly=downloadonly, + time_clip=time_clip, + no_update=no_update, + ) + + +def xrs( + trange=["2013-11-5", "2013-11-6"], + probe="15", + datatype="1min", + prefix="", + suffix="", + downloadonly=False, + no_update=False, + time_clip=False, +): """ This function loads data from the GOES X-ray Sensor (probes 8-18) @@ -416,22 +496,33 @@ def xrs(trange=['2013-11-5', '2013-11-6'], Time clip the variables to exactly the range specified in the trange keyword Returns - ---------- + ------- List of tplot variables created. Or list of filenames downloaded. """ - return load(instrument='xrs', trange=trange, probe=probe, datatype=datatype, prefix=prefix, suffix=suffix, - downloadonly=downloadonly, time_clip=time_clip, no_update=no_update) - - -def euvs(trange=['2023-01-30', '2023-01-31'], - probe='16', - datatype='1min', - prefix='', - suffix='', - downloadonly=False, - no_update=False, - time_clip=False): + return load( + instrument="xrs", + trange=trange, + probe=probe, + datatype=datatype, + prefix=prefix, + suffix=suffix, + downloadonly=downloadonly, + time_clip=time_clip, + no_update=no_update, + ) + + +def euvs( + trange=["2023-01-30", "2023-01-31"], + probe="16", + datatype="1min", + prefix="", + suffix="", + downloadonly=False, + no_update=False, + time_clip=False, +): """ This function loads data from the GOES Extreme Ultraviolet Sensor (EUVS), (probes 16-18) @@ -468,22 +559,33 @@ def euvs(trange=['2023-01-30', '2023-01-31'], Time clip the variables to exactly the range specified in the trange keyword Returns - ---------- + ------- List of tplot variables created. Or list of filenames downloaded. """ - return load(instrument='euvs', trange=trange, probe=probe, datatype=datatype, prefix=prefix, suffix=suffix, - downloadonly=downloadonly, time_clip=time_clip, no_update=no_update) - - -def mag(trange=['2023-01-30', '2023-01-31'], - probe='16', - datatype='1min', - prefix='', - suffix='', - downloadonly=False, - no_update=False, - time_clip=False): + return load( + instrument="euvs", + trange=trange, + probe=probe, + datatype=datatype, + prefix=prefix, + suffix=suffix, + downloadonly=downloadonly, + time_clip=time_clip, + no_update=no_update, + ) + + +def mag( + trange=["2023-01-30", "2023-01-31"], + probe="16", + datatype="1min", + prefix="", + suffix="", + downloadonly=False, + no_update=False, + time_clip=False, +): """ This function loads data from the GOES Magnetometer, (probes 16-18) @@ -520,22 +622,33 @@ def mag(trange=['2023-01-30', '2023-01-31'], Time clip the variables to exactly the range specified in the trange keyword Returns - ---------- + ------- List of tplot variables created. Or list of filenames downloaded. """ - return load(instrument='mag', trange=trange, probe=probe, datatype=datatype, prefix=prefix, suffix=suffix, - downloadonly=downloadonly, time_clip=time_clip, no_update=no_update) - - -def mpsh(trange=['2023-01-30', '2023-01-31'], - probe='16', - datatype='1min', - prefix='', - suffix='', - downloadonly=False, - no_update=False, - time_clip=False): + return load( + instrument="mag", + trange=trange, + probe=probe, + datatype=datatype, + prefix=prefix, + suffix=suffix, + downloadonly=downloadonly, + time_clip=time_clip, + no_update=no_update, + ) + + +def mpsh( + trange=["2023-01-30", "2023-01-31"], + probe="16", + datatype="1min", + prefix="", + suffix="", + downloadonly=False, + no_update=False, + time_clip=False, +): """ This function loads data from the GOES Magnetospheric Particle Sensor (MPS-HI), (probes 16-18) @@ -576,18 +689,29 @@ def mpsh(trange=['2023-01-30', '2023-01-31'], List of tplot variables created. Or list of filenames downloaded. """ - return load(instrument='mpsh', trange=trange, probe=probe, datatype=datatype, prefix=prefix, suffix=suffix, - downloadonly=downloadonly, time_clip=time_clip, no_update=no_update) - - -def sgps(trange=['2023-01-30', '2023-01-31'], - probe='16', - datatype='1min', - prefix='', - suffix='', - downloadonly=False, - no_update=False, - time_clip=False): + return load( + instrument="mpsh", + trange=trange, + probe=probe, + datatype=datatype, + prefix=prefix, + suffix=suffix, + downloadonly=downloadonly, + time_clip=time_clip, + no_update=no_update, + ) + + +def sgps( + trange=["2023-01-30", "2023-01-31"], + probe="16", + datatype="1min", + prefix="", + suffix="", + downloadonly=False, + no_update=False, + time_clip=False, +): """ This function loads data from the GOES Solar and Galactic Proton Sensor (SGPS), (probes 16-18) @@ -624,9 +748,18 @@ def sgps(trange=['2023-01-30', '2023-01-31'], Time clip the variables to exactly the range specified in the trange keyword Returns - ---------- + ------- List of tplot variables created. Or list of filenames downloaded. """ - return load(instrument='sgps', trange=trange, probe=probe, datatype=datatype, prefix=prefix, suffix=suffix, - downloadonly=downloadonly, time_clip=time_clip, no_update=no_update) + return load( + instrument="sgps", + trange=trange, + probe=probe, + datatype=datatype, + prefix=prefix, + suffix=suffix, + downloadonly=downloadonly, + time_clip=time_clip, + no_update=no_update, + ) diff --git a/pyspedas/goes/config.py b/pyspedas/goes/config.py index bb185062..6df5e764 100644 --- a/pyspedas/goes/config.py +++ b/pyspedas/goes/config.py @@ -1,12 +1,13 @@ import os -CONFIG = {'local_data_dir': 'goes_data/', - 'remote_data_dir': 'https://www.ncei.noaa.gov/data/goes-space-environment-monitor/access/'} +CONFIG = { + "local_data_dir": "goes_data/", + "remote_data_dir": "https://www.ncei.noaa.gov/data/goes-space-environment-monitor/access/", +} # 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'], 'goes']) +if os.environ.get("SPEDAS_DATA_DIR"): + CONFIG["local_data_dir"] = os.sep.join([os.environ["SPEDAS_DATA_DIR"], "goes"]) -if os.environ.get('GOES_DATA_DIR'): - CONFIG['local_data_dir'] = os.environ['GOES_DATA_DIR'] +if os.environ.get("GOES_DATA_DIR"): + CONFIG["local_data_dir"] = os.environ["GOES_DATA_DIR"] diff --git a/pyspedas/goes/load.py b/pyspedas/goes/load.py index 13dd6020..fd7ba107 100644 --- a/pyspedas/goes/load.py +++ b/pyspedas/goes/load.py @@ -6,15 +6,17 @@ from .config import CONFIG -def loadr(trange=['2023-01-01', '2032-01-02'], - probe='16', - instrument='mag', - datatype='1min', - prefix='', - suffix='', - downloadonly=False, - no_update=False, - time_clip=False): +def loadr( + trange=["2023-01-01", "2032-01-02"], + probe="16", + instrument="mag", + datatype="1min", + prefix="", + suffix="", + downloadonly=False, + no_update=False, + time_clip=False, +): """ This function loads GOES-R L2 data (GOES-16, GOES-17, GOES-18) @@ -104,8 +106,10 @@ def loadr(trange=['2023-01-01', '2032-01-02'], load(trange=trange, probe='16', instrument='mag', datatype='1min', time_clip=True) """ - goes_path_dir = 'https://data.ngdc.noaa.gov/platforms/solar-space-observing-satellites/goes/' - time_var = 'time' # name of the time variable in the netcdf files + goes_path_dir = ( + "https://data.ngdc.noaa.gov/platforms/solar-space-observing-satellites/goes/" + ) + time_var = "time" # name of the time variable in the netcdf files out_files = [] tvars = [] @@ -113,34 +117,96 @@ def loadr(trange=['2023-01-01', '2032-01-02'], probe = [probe] for prb in probe: - remote_path = 'goes' + str(prb) + '/l2/data/' - - if instrument == 'euvs': - if datatype in ['full', 'hi', '1min', 'avg1m']: # high resolution 1 min - pathformat = [remote_path + 'euvs-l2-avg1m_science/%Y/%m/sci_euvs-l2-avg1m_g' + str(prb) + '_d%Y%m%d_v?-?-?.nc'] + remote_path = "goes" + str(prb) + "/l2/data/" + + if instrument == "euvs": + if datatype in ["full", "hi", "1min", "avg1m"]: # high resolution 1 min + pathformat = [ + remote_path + + "euvs-l2-avg1m_science/%Y/%m/sci_euvs-l2-avg1m_g" + + str(prb) + + "_d%Y%m%d_v?-?-?.nc" + ] else: # low resolution 1 day, smaller files - pathformat = [remote_path + 'euvs-l2-avg1d_science/%Y/%m/sci_euvs-l2-avg1d_g' + str(prb) + '_d%Y%m%d_v?-?-?.nc'] - elif instrument == 'xrs': - if datatype in ['full', 'hi', '1sec', 'flx1s']: # high resolution 1 sec - pathformat = [remote_path + 'xrsf-l2-flx1s_science/%Y/%m/sci_xrsf-l2-flx1s_g' + str(prb) + '_d%Y%m%d_v?-?-?.nc'] + pathformat = [ + remote_path + + "euvs-l2-avg1d_science/%Y/%m/sci_euvs-l2-avg1d_g" + + str(prb) + + "_d%Y%m%d_v?-?-?.nc" + ] + elif instrument == "xrs": + if datatype in ["full", "hi", "1sec", "flx1s"]: # high resolution 1 sec + pathformat = [ + remote_path + + "xrsf-l2-flx1s_science/%Y/%m/sci_xrsf-l2-flx1s_g" + + str(prb) + + "_d%Y%m%d_v?-?-?.nc" + ] else: # low resolution 1 min, smaller files - pathformat = [remote_path + 'xrsf-l2-avg1m_science/%Y/%m/sci_xrsf-l2-avg1m_g' + str(prb) + '_d%Y%m%d_v?-?-?.nc'] - elif instrument == 'mag': - if datatype in ['full', 'hi', '0.1sec', 'hires']: # high resolution 0.1 sec - pathformat = [remote_path + 'magn-l2-hires/%Y/%m/dn_magn-l2-hires_g' + str(prb) + '_d%Y%m%d_v?-?-?.nc'] + pathformat = [ + remote_path + + "xrsf-l2-avg1m_science/%Y/%m/sci_xrsf-l2-avg1m_g" + + str(prb) + + "_d%Y%m%d_v?-?-?.nc" + ] + elif instrument == "mag": + if datatype in ["full", "hi", "0.1sec", "hires"]: # high resolution 0.1 sec + pathformat = [ + remote_path + + "magn-l2-hires/%Y/%m/dn_magn-l2-hires_g" + + str(prb) + + "_d%Y%m%d_v?-?-?.nc" + ] else: # low resolution 1 min, smaller files - pathformat = [remote_path + 'magn-l2-avg1m/%Y/%m/dn_magn-l2-avg1m_g' + str(prb) + '_d%Y%m%d_v?-?-?.nc'] - elif instrument == 'mpsh': - time_var = 'L2_SciData_TimeStamp' - if datatype in ['full', 'hi', '1min', 'avg1m', '1m']: # high resolution 1 min - pathformat = [remote_path + 'mpsh-l2-avg1m/%Y/%m/sci_mpsh-l2-avg1m_g' + str(prb) + '_d%Y%m%d_v?-?-?.nc'] + pathformat = [ + remote_path + + "magn-l2-avg1m/%Y/%m/dn_magn-l2-avg1m_g" + + str(prb) + + "_d%Y%m%d_v?-?-?.nc" + ] + elif instrument == "mpsh": + time_var = "L2_SciData_TimeStamp" + if datatype in [ + "full", + "hi", + "1min", + "avg1m", + "1m", + ]: # high resolution 1 min + pathformat = [ + remote_path + + "mpsh-l2-avg1m/%Y/%m/sci_mpsh-l2-avg1m_g" + + str(prb) + + "_d%Y%m%d_v?-?-?.nc" + ] else: # low resolution 5 min, smaller files - pathformat = [remote_path + 'mpsh-l2-avg5m/%Y/%m/sci_mpsh-l2-avg5m_g' + str(prb) + '_d%Y%m%d_v?-?-?.nc'] - elif instrument == 'sgps': - if datatype in ['full', 'hi', '1min', 'avg1m', '1m']: # high resolution 1 min - pathformat = [remote_path + 'sgps-l2-avg1m/%Y/%m/sci_sgps-l2-avg1m_g' + str(prb) + '_d%Y%m%d_v?-?-?.nc'] + pathformat = [ + remote_path + + "mpsh-l2-avg5m/%Y/%m/sci_mpsh-l2-avg5m_g" + + str(prb) + + "_d%Y%m%d_v?-?-?.nc" + ] + elif instrument == "sgps": + if datatype in [ + "full", + "hi", + "1min", + "avg1m", + "1m", + ]: # high resolution 1 min + pathformat = [ + remote_path + + "sgps-l2-avg1m/%Y/%m/sci_sgps-l2-avg1m_g" + + str(prb) + + "_d%Y%m%d_v?-?-?.nc" + ] else: # low resolution 5 min, smaller files - pathformat = [remote_path + 'sgps-l2-avg5m/%Y/%m/sci_sgps-l2-avg5m_g' + str(prb) + '_d%Y%m%d_v?-?-?.nc'] + pathformat = [ + remote_path + + "sgps-l2-avg5m/%Y/%m/sci_sgps-l2-avg5m_g" + + str(prb) + + "_d%Y%m%d_v?-?-?.nc" + ] # find the full remote path names using the trange if not isinstance(pathformat, list): @@ -150,7 +216,12 @@ def loadr(trange=['2023-01-01', '2032-01-02'], for path in pathformat: remote_names.extend(dailynames(file_format=path, trange=trange)) - files = download(remote_file=remote_names, remote_path=goes_path_dir, local_path=CONFIG['local_data_dir'], no_download=no_update) + files = download( + remote_file=remote_names, + remote_path=goes_path_dir, + local_path=CONFIG["local_data_dir"], + no_download=no_update, + ) if files is not None: for file in files: @@ -158,11 +229,13 @@ def loadr(trange=['2023-01-01', '2032-01-02'], tvars_local = [] if len(files) > 0 and downloadonly is False: - if prefix == 'probename': - prefix_local = 'g' + str(prb) + '_' + if prefix == "probename": + prefix_local = "g" + str(prb) + "_" else: prefix_local = prefix - tvars_local = netcdf_to_tplot(files, prefix=prefix_local, suffix=suffix, merge=True, time=time_var) + tvars_local = netcdf_to_tplot( + files, prefix=prefix_local, suffix=suffix, merge=True, time=time_var + ) if len(tvars_local): tvars.extend(tvars_local) @@ -173,20 +246,22 @@ def loadr(trange=['2023-01-01', '2032-01-02'], 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 -def load(trange=['2013-11-05', '2013-11-06'], - probe='15', - instrument='fgm', - datatype='1min', - prefix='', - suffix='', - downloadonly=False, - no_update=False, - time_clip=False): +def load( + trange=["2013-11-05", "2013-11-06"], + probe="15", + instrument="fgm", + datatype="1min", + prefix="", + suffix="", + downloadonly=False, + no_update=False, + time_clip=False, +): """ This function loads GOES L2 data @@ -266,105 +341,130 @@ def load(trange=['2013-11-05', '2013-11-06'], probe_s.append(str(prb)) if len(probe_r): - tvars_r = loadr(trange=trange, - probe=probe_r, - instrument=instrument, - datatype=datatype, - prefix=prefix, - suffix=suffix, - downloadonly=downloadonly, - no_update=no_update, - time_clip=time_clip) + tvars_r = loadr( + trange=trange, + probe=probe_r, + instrument=instrument, + datatype=datatype, + prefix=prefix, + suffix=suffix, + downloadonly=downloadonly, + no_update=no_update, + time_clip=time_clip, + ) if downloadonly: out_files_r = tvars_r # Continue with loading GOES (1-15) data for prb in probe_s: - avg_path = 'avg/%Y/%m/goes' + str(prb) + '/netcdf/' + 'g' + str(prb) - full_path = 'full/%Y/%m/goes' + str(prb) + '/netcdf/' + 'g' + str(prb) - - if instrument == 'fgm': - if datatype == '512ms' or datatype == 'full': # full, unaveraged data - pathformat = full_path + '_magneto_512ms_%Y%m%d_%Y%m%d.nc' - elif datatype == '5min': # 5 min averages - pathformat = avg_path + '_magneto_5m_%Y%m01_%Y%m??.nc' + avg_path = "avg/%Y/%m/goes" + str(prb) + "/netcdf/" + "g" + str(prb) + full_path = "full/%Y/%m/goes" + str(prb) + "/netcdf/" + "g" + str(prb) + + if instrument == "fgm": + if datatype == "512ms" or datatype == "full": # full, unaveraged data + pathformat = full_path + "_magneto_512ms_%Y%m%d_%Y%m%d.nc" + elif datatype == "5min": # 5 min averages + pathformat = avg_path + "_magneto_5m_%Y%m01_%Y%m??.nc" else: # 1 min averages, goes13, goes15 only contain 1m averages - pathformat = avg_path + '_magneto_1m_%Y%m01_%Y%m??.nc' - elif instrument == 'eps': + pathformat = avg_path + "_magneto_1m_%Y%m01_%Y%m??.nc" + elif instrument == "eps": # energetic particle sensor -- only valid for GOES-08 through GOES-12, only averaged data available - if datatype == '1min' or datatype == 'full': - pathformat = avg_path + '_eps_1m_%Y%m01_%Y%m??.nc' + if datatype == "1min" or datatype == "full": + pathformat = avg_path + "_eps_1m_%Y%m01_%Y%m??.nc" else: # 'low' or 5min - pathformat = avg_path + '_eps_5m_%Y%m01_%Y%m??.nc' - elif instrument == 'epead': + pathformat = avg_path + "_eps_5m_%Y%m01_%Y%m??.nc" + elif instrument == "epead": # electron, proton, alpha detector -- only valid on GOES-13, 14, 15 - if datatype == '1min': - pathformat = ['_epead_e13ew_1m_%Y%m01_%Y%m??.nc', - '_epead_p17ew_1m_%Y%m01_%Y%m??.c', - '_epead_a16ew_1m_%Y%m01_%Y%m??.nc'] + if datatype == "1min": + pathformat = [ + "_epead_e13ew_1m_%Y%m01_%Y%m??.nc", + "_epead_p17ew_1m_%Y%m01_%Y%m??.c", + "_epead_a16ew_1m_%Y%m01_%Y%m??.nc", + ] pathformat = [avg_path + s for s in pathformat] - elif datatype == '5min' or datatype == 'low': - pathformat = ['_epead_e13ew_5m_%Y%m01_%Y%m??.nc', - '_epead_p17ew_5m_%Y%m01_%Y%m??.c', - '_epead_a16ew_5m_%Y%m01_%Y%m??.nc'] + elif datatype == "5min" or datatype == "low": + pathformat = [ + "_epead_e13ew_5m_%Y%m01_%Y%m??.nc", + "_epead_p17ew_5m_%Y%m01_%Y%m??.c", + "_epead_a16ew_5m_%Y%m01_%Y%m??.nc", + ] pathformat = [avg_path + s for s in pathformat] else: # full - pathformat = ['_epead_a16e_32s_%Y%m%d_%Y%m%d.nc', - '_epead_a16w_32s_%Y%m%d_%Y%m%d.nc', - '_epead_e1ew_4s_%Y%m%d_%Y%m%d.nc', - '_epead_e2ew_16s_%Y%m%d_%Y%m%d.nc', - '_epead_e3ew_16s_%Y%m%d_%Y%m%d.nc', - '_epead_p1ew_8s_%Y%m%d_%Y%m%d.nc', - '_epead_p27e_32s_%Y%m%d_%Y%m%d.nc', - '_epead_p27w_32s_%Y%m%d_%Y%m%d.nc'] + pathformat = [ + "_epead_a16e_32s_%Y%m%d_%Y%m%d.nc", + "_epead_a16w_32s_%Y%m%d_%Y%m%d.nc", + "_epead_e1ew_4s_%Y%m%d_%Y%m%d.nc", + "_epead_e2ew_16s_%Y%m%d_%Y%m%d.nc", + "_epead_e3ew_16s_%Y%m%d_%Y%m%d.nc", + "_epead_p1ew_8s_%Y%m%d_%Y%m%d.nc", + "_epead_p27e_32s_%Y%m%d_%Y%m%d.nc", + "_epead_p27w_32s_%Y%m%d_%Y%m%d.nc", + ] pathformat = [full_path + s for s in pathformat] - elif instrument == 'maged': + elif instrument == "maged": # magnetospheric electron detector -- only valid on GOES 13, 14, 15 - if datatype == '1min': - pathformat = avg_path + '_maged_19me15_1m_%Y%m01_%Y%m??.nc' - elif datatype == '5min' or datatype == 'low': - pathformat = avg_path + '_maged_19me15_5m_%Y%m01_%Y%m??.nc' + if datatype == "1min": + pathformat = avg_path + "_maged_19me15_1m_%Y%m01_%Y%m??.nc" + elif datatype == "5min" or datatype == "low": + pathformat = avg_path + "_maged_19me15_5m_%Y%m01_%Y%m??.nc" else: # full - channels = ['me1', 'me2', 'me3', 'me4', 'me5'] - resolution = ['2', '2', '4', '16', '32'] + channels = ["me1", "me2", "me3", "me4", "me5"] + resolution = ["2", "2", "4", "16", "32"] pathformat = [] for idx, channel in enumerate(channels): - pathformat.append('_maged_19' + channel + '_' + resolution[idx] + 's_%Y%m%d_%Y%m%d.nc') + pathformat.append( + "_maged_19" + + channel + + "_" + + resolution[idx] + + "s_%Y%m%d_%Y%m%d.nc" + ) pathformat = [full_path + s for s in pathformat] - elif instrument == 'magpd': + elif instrument == "magpd": # magnetospheric proton detector -- only valid on GOES 13, 14, 15 - if datatype == '1min' or datatype == 'low': - pathformat = avg_path + '_magpd_19mp15_1m_%Y%m01_%Y%m??.nc' + if datatype == "1min" or datatype == "low": + pathformat = avg_path + "_magpd_19mp15_1m_%Y%m01_%Y%m??.nc" else: # full - channels = ['mp1', 'mp2', 'mp3', 'mp4', 'mp5'] - resolution = ['16', '16', '16', '32', '32'] + channels = ["mp1", "mp2", "mp3", "mp4", "mp5"] + resolution = ["16", "16", "16", "32", "32"] pathformat = [] for idx, channel in enumerate(channels): - pathformat.append('_magpd_19' + channel + '_'+resolution[idx] + 's_%Y%m%d_%Y%m%d.nc') + pathformat.append( + "_magpd_19" + + channel + + "_" + + resolution[idx] + + "s_%Y%m%d_%Y%m%d.nc" + ) pathformat = [full_path + s for s in pathformat] - elif instrument == 'hepad': + elif instrument == "hepad": # high energy proton and alpha detector -- valid for GOES 08-15 - if datatype == '1min': - pathformat = ['_hepad_ap_1m_%Y%m01_%Y%m??.nc', - '_hepad_s15_1m_%Y%m01_%Y%m??.nc'] + if datatype == "1min": + pathformat = [ + "_hepad_ap_1m_%Y%m01_%Y%m??.nc", + "_hepad_s15_1m_%Y%m01_%Y%m??.nc", + ] pathformat = [avg_path + s for s in pathformat] - elif datatype == '5min' or datatype == 'low': - pathformat = ['_hepad_ap_5m_%Y%m01_%Y%m??.nc', - '_hepad_s15_5m_%Y%m01_%Y%m??.nc'] + elif datatype == "5min" or datatype == "low": + pathformat = [ + "_hepad_ap_5m_%Y%m01_%Y%m??.nc", + "_hepad_s15_5m_%Y%m01_%Y%m??.nc", + ] pathformat = [avg_path + s for s in pathformat] else: - pathformat = ['_hepad_ap_32s_%Y%m%d_%Y%m%d.nc', - '_hepad_s15_4s_%Y%m%d_%Y%m%d.nc'] + pathformat = [ + "_hepad_ap_32s_%Y%m%d_%Y%m%d.nc", + "_hepad_s15_4s_%Y%m%d_%Y%m%d.nc", + ] pathformat = [full_path + s for s in pathformat] - elif instrument == 'xrs': + elif instrument == "xrs": # x-ray sensor -- valid for GOES 08-15 - if datatype == '1min': - pathformat = avg_path + '_xrs_1m_%Y%m01_%Y%m??.nc' - elif datatype == '5min' or datatype == 'low': - pathformat = avg_path + '_xrs_5m_%Y%m01_%Y%m??.nc' + if datatype == "1min": + pathformat = avg_path + "_xrs_1m_%Y%m01_%Y%m??.nc" + elif datatype == "5min" or datatype == "low": + pathformat = avg_path + "_xrs_5m_%Y%m01_%Y%m??.nc" else: - pathformat = ['_xrs_2s_%Y%m%d_%Y%m%d.nc', - '_xrs_3s_%Y%m%d_%Y%m%d.nc'] + pathformat = ["_xrs_2s_%Y%m%d_%Y%m%d.nc", "_xrs_3s_%Y%m%d_%Y%m%d.nc"] pathformat = [full_path + s for s in pathformat] # find the full remote path names using the trange @@ -375,18 +475,25 @@ def load(trange=['2013-11-05', '2013-11-06'], for path in pathformat: remote_names.extend(dailynames(file_format=path, trange=trange)) - 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) tvars_local = [] if len(files) > 0 and downloadonly is False: - if prefix == 'probename': - prefix_local = 'g' + str(prb) + '_' + if prefix == "probename": + prefix_local = "g" + str(prb) + "_" else: prefix_local = prefix - tvars_local = netcdf_to_tplot(files, prefix=prefix_local, suffix=suffix, merge=True, time='time_tag') + tvars_local = netcdf_to_tplot( + files, prefix=prefix_local, suffix=suffix, merge=True, time="time_tag" + ) if len(tvars_local) > 0: tvars.extend(tvars_local) @@ -398,7 +505,7 @@ def load(trange=['2013-11-05', '2013-11-06'], if time_clip: for new_var in tvars: - tclip(new_var, trange[0], trange[1], suffix='') + tclip(new_var, trange[0], trange[1], suffix="") if len(tvars_r): tvars.extend(tvars_r) # append GOES-R variables diff --git a/pyspedas/goes/load_orbit.py b/pyspedas/goes/load_orbit.py index fa8f9e68..c85797ef 100644 --- a/pyspedas/goes/load_orbit.py +++ b/pyspedas/goes/load_orbit.py @@ -6,17 +6,19 @@ from .config import CONFIG -def load_orbit(trange=['2013-11-5', '2013-11-6'], - probe='15', - prefix='', - suffix='', - get_support_data=False, - varformat=None, - varnames=[], - downloadonly=False, - notplot=False, - no_update=False, - time_clip=True): +def load_orbit( + trange=["2013-11-5", "2013-11-6"], + probe="15", + prefix="", + suffix="", + get_support_data=False, + varformat=None, + varnames=[], + downloadonly=False, + notplot=False, + no_update=False, + time_clip=True, +): """ This function loads GOES orbit data from SPDF: @@ -56,11 +58,11 @@ def load_orbit(trange=['2013-11-5', '2013-11-6'], Time clip the variables to exactly the range specified in the trange keyword Returns - ---------- + ------- List of tplot variables created. Or list of filenames downloaded. """ - remote_data_dir = 'https://spdf.gsfc.nasa.gov/pub/data/goes/' + remote_data_dir = "https://spdf.gsfc.nasa.gov/pub/data/goes/" out_files = [] # list of local files downloaded tvars = [] # list of tplot variables created @@ -68,15 +70,24 @@ def load_orbit(trange=['2013-11-5', '2013-11-6'], probe = [probe] for prb in probe: - # yearly files - pathformat = 'goes' + str(prb) + '/orbit/%Y/goes' + str(prb) + '_ephemeris_ssc_%Y0101_v??.cdf' + pathformat = ( + "goes" + + str(prb) + + "/orbit/%Y/goes" + + str(prb) + + "_ephemeris_ssc_%Y0101_v??.cdf" + ) # find the full remote path names using the trange remote_names = dailynames(file_format=pathformat, trange=trange) - files = download(remote_file=remote_names, remote_path=remote_data_dir, - local_path=CONFIG['local_data_dir'], no_download=no_update) + files = download( + remote_file=remote_names, + remote_path=remote_data_dir, + local_path=CONFIG["local_data_dir"], + no_download=no_update, + ) out_files_local = [] @@ -88,18 +99,25 @@ def load_orbit(trange=['2013-11-5', '2013-11-6'], tvars_local = [] if not downloadonly: - if prefix == 'probename': - prefix_local = 'g' + str(prb) + '_' + if prefix == "probename": + prefix_local = "g" + str(prb) + "_" else: prefix_local = prefix - tvars_local = cdf_to_tplot(out_files_local, prefix=prefix_local, suffix=suffix, get_support_data=get_support_data, - varformat=varformat, varnames=varnames, notplot=notplot) + tvars_local = cdf_to_tplot( + out_files_local, + prefix=prefix_local, + suffix=suffix, + get_support_data=get_support_data, + varformat=varformat, + varnames=varnames, + notplot=notplot, + ) tvars.extend(tvars_local) if time_clip: for new_var in tvars_local: - tclip(new_var, trange[0], trange[1], suffix='') + tclip(new_var, trange[0], trange[1], suffix="") if downloadonly: return out_files