Ejemplo n.º 1
0
def load(trange=['2013-11-5', '2013-11-6'],
         datatype='1min',
         level='hro2',
         suffix='',
         get_support_data=False,
         get_ignore_data=False,
         varformat=None,
         varnames=[],
         downloadonly=False,
         notplot=False,
         no_update=False,
         time_clip=True):
    """
    This function loads OMNI (Combined 1AU IP Data; Magnetic and Solar Indices) data; this function is not meant 
    to be called directly; instead, see the wrapper:
        pyspedas.omni.data

    """

    if 'min' in datatype:
        pathformat = level + '_' + datatype + '/%Y/omni_' + level + '_' + datatype + '_%Y%m01_v??.cdf'
    elif 'hour' in datatype:
        pathformat = 'hourly/%Y/omni2_h0_mrg1hr_%Y%m01_v??.cdf'
    else:
        raise TypeError("%r are invalid keyword arguments" % datatype)

    # 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)
    if files is not None:
        for file in files:
            out_files.append(file)

    out_files = sorted(out_files)

    if downloadonly:
        return out_files

    tvars = cdf_to_tplot(out_files,
                         suffix=suffix,
                         get_support_data=get_support_data,
                         get_ignore_data=get_ignore_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='')

    return tvars
Ejemplo n.º 2
0
def load(trange=['2019-02-01', '2019-02-02'],
         site=None,
         suffix='',
         get_support_data=False,
         varformat=None,
         downloadonly=False,
         notplot=False,
         no_update=False,
         time_clip=False):
    """
    This function loads Magnetic Induction Coil Array (MICA) data; this function is not meant 
    to be called directly; instead, see the wrapper:
        pyspedas.mica.induction

    """

    if site == None:
        print('A valid MICA site code name must be entered.')
        print('Current site codes include: ')
        print(
            'NAL, LYR, LOR, ISR, SDY, IQA, SNK, MCM, SPA, JBS, NEV, HAL, PG2[3,4,5]'
        )
        return

    pathformat = site.upper() + '/%Y/%m/mica_ulf_' + site.lower(
    ) + '_%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)
    if files is not None:
        for file in files:
            out_files.append(file)

    out_files = sorted(out_files)

    if downloadonly:
        return out_files

    tvars = cdf_to_tplot(out_files,
                         suffix='_' + site.upper() + suffix,
                         merge=True,
                         get_support_data=get_support_data,
                         varformat=varformat,
                         notplot=notplot)

    if notplot:
        return tvars

    if time_clip:
        for new_var in tvars:
            tclip(new_var, trange[0], trange[1], suffix='')

    return tvars
Ejemplo n.º 3
0
    def download(self,
                 remote_files,
                 local_dir,
                 download_only=False,
                 varformat=None,
                 get_support_data=False,
                 prefix='',
                 suffix=''):
        """ Download cdf files.
            Load cdf files into pytplot variables.
            TODO: Loading files into pytplot sometimes does not work.
        """

        result = []
        loaded_vars = []
        remotehttp = "https://cdaweb.gsfc.nasa.gov/sp_phys/data"
        count = 0
        dcount = 0
        for remotef in remote_files:
            tplot_loaded = 0
            f = remotef.strip().replace(remotehttp, '', 1)
            localf = local_dir + os.path.sep + f
            localfile = download(remote_file=remotef, local_file=localf)
            if localfile == None:
                continue
            localfile = localfile[0]  # download returns an array
            count += 1
            if localfile != '':
                dcount += 1
                if not download_only:
                    try:
                        cdf_vars = pytplot.cdf_to_tplot(
                            localfile, varformat, get_support_data, prefix,
                            suffix, False, True)
                        if cdf_vars != [] and cdf_vars != None:
                            loaded_vars.extend(cdf_vars)
                        tplot_loaded = 1
                    except ValueError as err:
                        msg = "cdf_to_tplot could not load " + localfile
                        msg += "\n\n"
                        msg += "Error from pytplot: " + str(err)
                        print(msg)
                        tplot_loaded = 0
            else:
                print(
                    str(count) + '. There was a problem. Could not download \
                      file: ' + remotef)
                tplot_loaded = -1
                localfile = ''
            result.append([remotef, localfile, tplot_loaded])

        print('Downloaded ' + str(dcount) + ' files.')
        if not download_only:
            loaded_vars = list(set(loaded_vars))
            print('tplot variables:')
            for var in loaded_vars:
                print(var)

        return result
Ejemplo n.º 4
0
def load(trange=['2018-11-5', '2018-11-6'],
         probe=['noaa19'],
         instrument='sem',
         datatype='*',
         suffix='',
         get_support_data=False,
         varformat=None,
         varnames=[],
         downloadonly=False,
         notplot=False,
         no_update=False,
         time_clip=False):
    """
    This function loads POES Space Environment Monitor data. This function is
    not meant to be called directly; instead, see the wrapper:
        pyspedas.poes.sem
    
    """

    if not isinstance(probe, list):
        probe = [probe]

    out_files = []

    for prb in probe:
        if instrument == 'sem':
            pathformat = prb + '/sem2_fluxes-2sec/%Y/' + prb + '_poes-sem2_fluxes-2sec_%Y%m%d_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=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)

    out_files = sorted(out_files)

    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)

    if notplot:
        return tvars

    if time_clip:
        for new_var in tvars:
            tclip(new_var, trange[0], trange[1], suffix='')

    return tvars
Ejemplo n.º 5
0
def load(trange=['2013-11-5', '2013-11-6'], 
         instrument='dcb',
         datatype='', 
         level='l2', 
         suffix='', 
         get_support_data=False, 
         varformat=None,
         downloadonly=False,
         notplot=False,
         no_update=False,
         time_clip=False):
    """
    This function loads data from the FAST mission; this function is not meant 
    to be called directly; instead, see the wrappers:
        pyspedas.fast.dcb
        pyspedas.fast.acb
        pyspedas.fast.esa
        pyspedas.fast.teams

    """
    file_resolution = 24*3600.

    if instrument == 'dcb':
        pathformat = 'dcf/'+level+'/'+instrument+'/%Y/%m/fast_hr_'+instrument+'_%Y%m%d%H????_v??.cdf'
        file_resolution = 3600.
    if instrument == 'acb':
        pathformat = 'acf/'+level+'/%Y/fa_'+level+'_acf_%Y%m%d_v??.cdf'
    elif instrument == 'esa':
        pathformat = instrument+'/'+level+'/'+datatype+'/%Y/%m/fa_'+instrument+'_'+level+'_'+datatype+'_%Y%m%d??????_*_v??.cdf'
    if instrument == 'teams':
        pathformat = 'teams/'+level+'/%Y/fa_'+level+'_tms_%Y%m%d_v??.cdf'

    # find the full remote path names using the trange
    remote_names = dailynames(file_format=pathformat, trange=trange, res=file_resolution)

    out_files = []

    for remote_file in remote_names:
        files = download(remote_file=remote_file, 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)

    out_files = sorted(out_files)

    if downloadonly:
        return out_files

    tvars = cdf_to_tplot(out_files, suffix=suffix, merge=True, get_support_data=get_support_data, varformat=varformat, notplot=notplot)
    
    if notplot:
        return tvars

    if time_clip:
        for new_var in tvars:
            tclip(new_var, trange[0], trange[1], suffix='')

    return tvars
Ejemplo n.º 6
0
def load(trange=['2020-06-01', '2020-06-02'], 
         instrument='mag',
         datatype='rtn-normal', 
         mode=None,
         level='l2', 
         suffix='', 
         get_support_data=False, 
         varformat=None,
         varnames=[],
         downloadonly=False,
         notplot=False,
         no_update=False,
         time_clip=False):
    """
    This function loads data from the Solar Orbiter mission; this function is not meant 
    to be called directly; instead, see the wrappers:
        pyspedas.solo.mag
        pyspedas.solo.epd
        pyspedas.solo.rpw
        pyspedas.solo.swa

    """

    if instrument == 'mag':
        pathformat = instrument+'/science/'+level+'/'+datatype+'/%Y/solo_'+level+'_'+instrument+'-'+datatype+'_%Y%m%d_v??.cdf'
    elif instrument == 'epd':
        pathformat = instrument+'/science/'+level+'/'+datatype+'/'+mode+'/%Y/solo_'+level+'_'+instrument+'-'+datatype+'-'+mode+'_%Y%m%d_v??.cdf'
    elif instrument == 'rpw':
        pathformat = instrument+'/science/'+level+'/'+datatype+'/%Y/solo_'+level+'_'+instrument+'-'+datatype+'_%Y%m%d_v??.cdf'
    elif instrument == 'swa':
        if datatype == 'pas-eflux':
            pathformat = instrument+'/science/'+level+'/'+datatype+'/%Y/solo_'+level+'_'+instrument+'-'+datatype+'_%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)
    if files is not None:
        for file in files:
            out_files.append(file)

    out_files = sorted(out_files)

    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)
    
    if notplot:
        return tvars

    if time_clip:
        for new_var in tvars:
            tclip(new_var, trange[0], trange[1], suffix='')

    return tvars
def mms_load_fast_segments(trange=None, suffix=''):
    '''
    This function loads the fast segment intervals
    
    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']

    Returns:
        Tuple containing (start_times, end_times)

    '''

    if trange == None:
        logging.error('Error; no trange specified.')
        return None

    tr = time_double(trange)

    save_file = os.path.join(CONFIG['local_data_dir'], 'mms_fast_intervals.sav')
    fast_file = download(remote_file='http://www.spedas.org/mms/mms_fast_intervals.sav',
        local_file=save_file)

    try:
        intervals = readsav(save_file)
    except FileNotFoundError:
        logging.error('Error loading fast intervals sav file: ' + save_file)
        return None

    unix_start = np.flip(intervals['fast_intervals'].start_times[0])
    unix_end = np.flip(intervals['fast_intervals'].end_times[0])

    times_in_range = (unix_start >= tr[0]-2*86400.0) & (unix_start <= tr[1]+2*86400.0)

    unix_start = unix_start[times_in_range]
    unix_end = unix_end[times_in_range]

    bar_x = []
    bar_y = []

    for start_time, end_time in zip(unix_start, unix_end):
        if end_time >= tr[0] and start_time <= tr[1]:
            bar_x.extend([start_time, start_time, end_time, end_time])
            bar_y.extend([np.nan, 0., 0., np.nan])

    vars_created = store_data('mms_bss_fast'+suffix, data={'x': bar_x, 'y': bar_y})
    options('mms_bss_fast'+suffix, 'panel_size', 0.09)
    options('mms_bss_fast'+suffix, 'thick', 20)
    options('mms_bss_fast'+suffix, 'Color', 'green')
    options('mms_bss_fast'+suffix, 'border', False)
    options('mms_bss_fast'+suffix, 'yrange', [-0.001,0.001])
    options('mms_bss_fast'+suffix, 'legend_names', ['Fast'])
    options('mms_bss_fast'+suffix, 'ytitle', '')

    return (unix_start, unix_end)
Ejemplo n.º 8
0
def load(trange=['2013-11-5', '2013-11-6'],
         instrument='reptile',
         datatype='flux',
         level='l2',
         suffix='',
         get_support_data=False,
         varformat=None,
         downloadonly=False,
         notplot=False,
         no_update=False,
         time_clip=False):
    """
    This function loads data from the CSSWE mission; this function is not meant 
    to be called directly; instead, see the wrapper:
        pyspedas.csswe.reptile

    """

    if instrument == 'reptile':
        pathformat = level + '/' + instrument + '/' + datatype + '/%Y/csswe_' + instrument + '_6sec-' + datatype + '-' + level + '_%Y%m%d_v??.cdf'

    # find the full remote path names using the trange
    remote_names = dailynames(file_format=pathformat, trange=trange)

    out_files = []

    for remote_file in remote_names:
        files = download(remote_file=remote_file,
                         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)

    out_files = sorted(out_files)

    if downloadonly:
        return out_files

    tvars = cdf_to_tplot(out_files,
                         suffix=suffix,
                         merge=True,
                         get_support_data=get_support_data,
                         varformat=varformat,
                         notplot=notplot)

    if notplot:
        return tvars

    if time_clip:
        for new_var in tvars:
            tclip(new_var, trange[0], trange[1], suffix='')

    return tvars
Ejemplo n.º 9
0
def get_w(trange=None, create_tvar=False, newname=None):
    """
    This routine downloads the 6 Tsygeneko (TS05) model 
    driving variables W1, W2, W3, W4, W5, W6; from:

    http://geo.phys.spbu.ru/~tsyganenko/TS05_data_and_stuff
    """

    if trange is None:
        print('trange keyword must be specified.')
        return

    years = dailynames(trange=trange, file_format='%Y')
    tmpdir = mkdtemp()

    if newname is None:
        newname = 'Tsy_W_vars_' + '-'.join(years)

    ut_out = np.empty(0)
    w1_out = np.empty(0)
    w2_out = np.empty(0)
    w3_out = np.empty(0)
    w4_out = np.empty(0)
    w5_out = np.empty(0)
    w6_out = np.empty(0)

    for year in years:
        file = download(
            remote_path=
            'http://geo.phys.spbu.ru/~tsyganenko/TS05_data_and_stuff/',
            remote_file=year + '_OMNI_5m_with_TS05_variables.???',
            local_path=tmpdir)

        if file[0][-3:] == 'zip':
            with zipfile.ZipFile(file[0], 'r') as zip_ref:
                zip_ref.extractall(tmpdir)

        rows = pd.read_csv(tmpdir + '/' + year +
                           '_OMNI_5m_with_TS05_variables.dat',
                           delim_whitespace=True,
                           header=None)

        # extract the W variables
        w1 = rows.to_numpy()[:, -6]
        w2 = rows.to_numpy()[:, -5]
        w3 = rows.to_numpy()[:, -4]
        w4 = rows.to_numpy()[:, -3]
        w5 = rows.to_numpy()[:, -2]
        w6 = rows.to_numpy()[:, -1]

        # extract the times
        years = rows.to_numpy()[:, 0]
        doys = rows.to_numpy()[:, 1]
        hours = rows.to_numpy()[:, 2]
        minutes = rows.to_numpy()[:, 3]
        time_strings = [
            str(int(year)) + '-' + str(int(doy)).zfill(3) + ' ' +
            str(int(hour)).zfill(2) + ':' + str(int(minute)).zfill(2)
            for year, doy, hour, minute in zip(years, doys, hours, minutes)
        ]
        unix_times = np.array(time_double(time_strings))

        ut_out = np.append(ut_out, unix_times)
        w1_out = np.append(w1_out, w1)
        w2_out = np.append(w2_out, w2)
        w3_out = np.append(w3_out, w3)
        w4_out = np.append(w4_out, w4)
        w5_out = np.append(w5_out, w5)
        w6_out = np.append(w6_out, w6)

    in_range = np.argwhere((ut_out >= time_double(trange[0]))
                           & (ut_out < time_double(trange[1]))).squeeze()

    if len(in_range) == 0:
        print('No data found in the trange.')
        return

    if create_tvar:
        out = np.array((w1_out[in_range], w2_out[in_range], w3_out[in_range],
                        w4_out[in_range], w5_out[in_range], w6_out[in_range]))
        store_data(newname, data={'x': ut_out[in_range], 'y': out.T})
        return newname

    return {
        'times': ut_out[in_range],
        'w1': w1_out[in_range],
        'w2': w2_out[in_range],
        'w3': w3_out[in_range],
        'w4': w4_out[in_range],
        'w5': w5_out[in_range],
        'w6': w6_out[in_range]
    }
Ejemplo n.º 10
0
def load(trange=None,
         resolution=10,
         dtype=None,
         no_download=False,
         downloadonly=False,
         out_type='np',
         save_pickle=False):
    """
    This function loads SECS/EICS data; this function is not meant
    to be called directly; instead, see the wrapper:
        pyspedas.secs.data

    """

    if dtype == 'EICS' or dtype == 'SECS':
        pathformat_prefix = dtype + '/%Y/%m/'
        pathformat_zip = pathformat_prefix + dtype + '%Y%m%d.zip'
        pathformat_gz = pathformat_prefix + dtype + '%Y%m%d.zip.gz'  # only 2007!
        pathformat_unzipped = pathformat_prefix + '%d/' + dtype + '%Y%m%d_%H%M%S.dat'

    else:
        raise TypeError("%r are invalid keyword arguments" % dtype)

    # find the full remote path names using the trange
    remote_names = dailynames(file_format=pathformat_zip, trange=trange)
    remote_names_gz = dailynames(file_format=pathformat_gz, trange=trange)
    remote_names_gz = [s for s in remote_names_gz if s[-15:-11] == '2007']

    out_files = []
    out_files_zip = []

    files_zip = download(remote_file=remote_names,
                         remote_path=CONFIG['remote_data_dir'],
                         local_path=CONFIG['local_data_dir'],
                         no_download=no_download)
    files_gz = download(remote_file=remote_names_gz,
                        remote_path=CONFIG['remote_data_dir'],
                        local_path=CONFIG['local_data_dir'],
                        no_download=no_download)
    files_zip = files_zip + files_gz

    if files_zip is not None:
        for rf_zip_zero in files_zip:
            if rf_zip_zero.endswith('.gz'):
                rf_zip = rf_zip_zero[0:-3]
                # unzip .gz file to .zip file
                with gzip.open(rf_zip_zero, 'rb') as f_in:
                    with open(rf_zip, 'wb') as f_out:
                        shutil.copyfileobj(f_in, f_out)
            elif rf_zip_zero.endswith('.zip'):
                rf_zip = rf_zip_zero
            else:
                rf_zip = rf_zip_zero
            out_files_zip.append(rf_zip)
            #print('Start for unzipping process ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
            foldername_unzipped = rf_zip[0:-19] + rf_zip[-8:-6] + '/' + rf_zip[
                -6:-4]
            #print('foldername_unzipped-------: ', foldername_unzipped)
            ### add??????
            if not os.path.isdir(foldername_unzipped):
                logging.info('Start unzipping: ' + rf_zip + '  ------')
                with zipfile.ZipFile(rf_zip, 'r') as zip_ref:
                    zip_ref.extractall(rf_zip[0:-16])
                if not os.path.isdir(foldername_unzipped):
                    # for the case of unzipping directly without the %d folder made.
                    # make %d folder
                    os.makedirs(foldername_unzipped)
                    # move .dat files
                    sourcepath = rf_zip[0:-16]
                    sourcefiles = os.listdir(sourcepath)
                    destinationpath = foldername_unzipped
                    logging.info('start to move files: --------------')
                    for file in sourcefiles:
                        if rf_zip[-16:-4] in file and file.endswith('.dat'):
                            shutil.move(os.path.join(sourcepath, file),
                                        os.path.join(destinationpath, file))

            else:
                logging.info('Unzipped folder: ' + foldername_unzipped +
                             ' existed, skip unzipping  ------')

    if files_zip is not None:
        for file in files_zip:
            out_files.append(file)
    out_files = sorted(out_files)

    if out_files_zip is not None:
        out_files_zip = list(set(out_files_zip))
        out_files_zip = sorted(out_files_zip)

    if downloadonly:
        return out_files_zip  #out_files

    remote_names_unzipped = dailynames(file_format=pathformat_unzipped,
                                       trange=trange,
                                       res=resolution)
    """
    files_unzipped = download(remote_file=remote_names_unzipped, remote_path=CONFIG['remote_data_dir'],
                         local_path=CONFIG['local_data_dir'], no_download=True)
    """
    remote_names_unzipped_existed = [
        rnud for rnud in remote_names_unzipped for ofz in out_files_zip
        if ofz[-16:-4] in rnud
    ]
    remote_names_unzipped = remote_names_unzipped_existed
    out_files_unzipped = [
        CONFIG['local_data_dir'] + rf_res for rf_res in remote_names_unzipped
    ]
    out_files_unzipped = sorted(out_files_unzipped)

    if out_files_unzipped == []:
        data_vars = []
    else:
        data_vars = pyspedas.secs.read_data_files(out_files=out_files_unzipped,
                                                  dtype=dtype,
                                                  out_type=out_type,
                                                  save_pickle=save_pickle)
        #print('data_vars: ', data_vars, np.shape(data_vars))

    return data_vars  #tvars
Ejemplo n.º 11
0
def load(trange=['2013-11-5', '2013-11-6'],
         instrument='mgf',
         datatype='k0',
         suffix='',
         get_support_data=False,
         varformat=None,
         varnames=[],
         downloadonly=False,
         notplot=False,
         no_update=False,
         time_clip=False):
    """
    This function loads data from the Geotail mission; this function is not meant 
    to be called directly; instead, see the wrappers:
        pyspedas.geotail.mgf
        pyspedas.geotail.efd
        pyspedas.geotail.lep
        pyspedas.geotail.cpi
        pyspedas.geotail.epi
        pyspedas.geotail.pwi

    """

    tvars_created = []

    if instrument == 'mgf':
        if datatype == 'k0':
            pathformat = 'mgf/mgf_k0/%Y/ge_' + datatype + '_mgf_%Y%m%d_v??.cdf'
        elif datatype == 'eda3sec' or datatype == 'edb3sec':
            pathformat = 'mgf/' + datatype + '_mgf/%Y/ge_' + datatype + '_mgf_%Y%m%d_v??.cdf'
    elif instrument == 'efd':
        pathformat = instrument + '/' + instrument + '_' + datatype + '/%Y/ge_' + datatype + '_' + instrument + '_%Y%m%d_v??.cdf'
    elif instrument == 'lep':
        if datatype == 'k0':
            pathformat = 'lep/lep_k0/%Y/ge_' + datatype + '_lep_%Y%m%d_v??.cdf'
    elif instrument == 'cpi':
        pathformat = instrument + '/' + instrument + '_' + datatype + '/%Y/ge_' + datatype + '_' + instrument + '_%Y%m%d_v??.cdf'
    elif instrument == 'epi':
        pathformat = 'epic/' + instrument + '_' + datatype + '/%Y/ge_' + datatype + '_' + instrument + '_%Y%m%d_v??.cdf'
    elif instrument == 'pwi':
        pathformat = instrument + '/' + instrument + '_' + datatype + '/%Y/ge_' + datatype + '_' + instrument + '_%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)
    if files is not None:
        for file in files:
            out_files.append(file)

    out_files = sorted(out_files)

    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)

    if notplot:
        return tvars

    if time_clip:
        for new_var in tvars:
            tclip(new_var, trange[0], trange[1], suffix='')

    return tvars
Ejemplo n.º 12
0
def load(trange=['2018-11-5', '2018-11-6'],
         probe='1',
         instrument='fgm',
         datatype='up',
         suffix='',
         get_support_data=False,
         varformat=None,
         varnames=[],
         downloadonly=False,
         notplot=False,
         no_update=False,
         time_clip=False):
    """
    This function loads data from the Cluster mission; this function is not meant 
    to be called directly; instead, see the wrappers:
        pyspedas.cluster.fgm
        pyspedas.cluster.aspoc
        pyspedas.cluster.cis
        pyspedas.cluster.dwp
        pyspedas.cluster.edi
        pyspedas.cluster.efw
        pyspedas.cluster.peace
        pyspedas.cluster.rapid
        pyspedas.cluster.staff
        pyspedas.cluster.wbd
        pyspedas.cluster.whi

    """

    if not isinstance(probe, list):
        probe = [probe]

    probe = [str(prb)
             for prb in probe]  # these will need to be strings from now on

    out_files = []

    res = 24 * 3600

    if instrument != 'wbd':
        # note: can't use last_version with WBD data due to using wild cards for the times (and not just in the version)
        last_version = True
    else:
        last_version = False

    for prb in probe:
        if instrument == 'fgm':
            if datatype == 'cp':
                pathformat = 'c' + prb + '/cp/%Y/c' + prb + '_cp_fgm_spin_%Y%m%d_v??.cdf'
            else:
                pathformat = 'c' + prb + '/' + datatype + '/' + instrument + '/%Y/c' + prb + '_' + datatype + '_' + instrument + '_%Y%m%d_v??.cdf'
        elif instrument == 'aspoc':
            pathformat = 'c' + prb + '/' + datatype + '/asp/%Y/c' + prb + '_' + datatype + '_asp_%Y%m%d_v??.cdf'
        elif instrument == 'cis':
            pathformat = 'c' + prb + '/' + datatype + '/' + instrument + '/%Y/c' + prb + '_' + datatype + '_' + instrument + '_%Y%m%d_v??.cdf'
        elif instrument == 'dwp':
            pathformat = 'c' + prb + '/' + datatype + '/' + instrument + '/%Y/c' + prb + '_' + datatype + '_' + instrument + '_%Y%m%d_v??.cdf'
        elif instrument == 'edi':
            pathformat = 'c' + prb + '/' + datatype + '/' + instrument + '/%Y/c' + prb + '_' + datatype + '_' + instrument + '_%Y%m%d_v??.cdf'
        elif instrument == 'efw':
            pathformat = 'c' + prb + '/' + datatype + '/' + instrument + '/%Y/c' + prb + '_' + datatype + '_' + instrument + '_%Y%m%d_v??.cdf'
        elif instrument == 'peace':
            pathformat = 'c' + prb + '/' + datatype + '/pea/%Y/c' + prb + '_' + datatype + '_pea_%Y%m%d_v??.cdf'
        elif instrument == 'rapid':
            pathformat = 'c' + prb + '/' + datatype + '/rap/%Y/c' + prb + '_' + datatype + '_rap_%Y%m%d_v??.cdf'
        elif instrument == 'staff':
            pathformat = 'c' + prb + '/' + datatype + '/sta/%Y/c' + prb + '_' + datatype + '_sta_%Y%m%d_v??.cdf'
        elif instrument == 'whi':
            pathformat = 'c' + prb + '/' + datatype + '/' + instrument + '/%Y/c' + prb + '_' + datatype + '_' + instrument + '_%Y%m%d_v??.cdf'
        elif instrument == 'wbd':
            pathformat = 'c' + prb + '/' + instrument + '/%Y/%m/c' + prb + '_' + datatype + '_' + instrument + '_%Y%m%d%H%M_v??.cdf'
            res = 600.0

        # find the full remote path names using the trange
        remote_names = dailynames(file_format=pathformat,
                                  trange=trange,
                                  res=res)

        files = download(remote_file=remote_names,
                         remote_path=CONFIG['remote_data_dir'],
                         local_path=CONFIG['local_data_dir'],
                         no_download=no_update,
                         last_version=last_version)
        if files is not None:
            for file in files:
                out_files.append(file)

    out_files = sorted(out_files)

    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)

    if notplot:
        return tvars

    if time_clip:
        for new_var in tvars:
            tclip(new_var, trange[0], trange[1], suffix='')

    return tvars
Ejemplo n.º 13
0
 def test_auth(self):
     files = download(remote_file='https://postman-echo.com/basic-auth', local_file='test_auth')
     self.assertTrue(len(files) == 0)
     files = download(remote_file='https://postman-echo.com/basic-auth', local_file='test_auth_works', username='******', password='******')
     self.assertTrue(len(files) == 1)
Ejemplo n.º 14
0
def load(trange=['1998-04-06', '1998-04-07'],
         instrument='mam',
         datatype='pp',
         suffix='',
         get_support_data=False,
         varformat=None,
         varnames=[],
         downloadonly=False,
         notplot=False,
         no_update=False,
         time_clip=False):
    """
    This function loads data from the Equator-S mission; this function is not meant 
    to be called directly; instead, see the wrappers:
        pyspedas.equator_s.mam
        pyspedas.equator_s.edi
        pyspedas.equator_s.esa (3DA)
        pyspedas.equator_s.epi
        pyspedas.equator_s.ici
        pyspedas.equator_s.pcd
        pyspedas.equator_s.sfd

    """

    if instrument == 'mam':
        pathformat = datatype + '/' + instrument + '/%Y/eq_' + datatype + '_' + instrument + '_%Y%m%d_v??.cdf'
    elif instrument == 'edi':
        pathformat = datatype + '/' + instrument + '/%Y/eq_' + datatype + '_' + instrument + '_%Y%m%d_v??.cdf'
    elif instrument == '3da':
        pathformat = datatype + '/' + instrument + '/%Y/eq_' + datatype + '_' + instrument + '_%Y%m%d_v??.cdf'
    elif instrument == 'epi':
        pathformat = datatype + '/' + instrument + '/%Y/eq_' + datatype + '_' + instrument + '_%Y%m%d_v??.cdf'
    elif instrument == 'ici':
        pathformat = datatype + '/' + instrument + '/%Y/eq_' + datatype + '_' + instrument + '_%Y%m%d_v??.cdf'
    elif instrument == 'pcd':
        pathformat = datatype + '/' + instrument + '/%Y/eq_' + datatype + '_' + instrument + '_%Y%m%d_v??.cdf'
    elif instrument == 'sfd':
        pathformat = datatype + '/' + instrument + '/%Y/eq_' + datatype + '_' + instrument + '_%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)
    if files is not None:
        for file in files:
            out_files.append(file)

    out_files = sorted(out_files)

    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)

    if notplot:
        return tvars

    if time_clip:
        for new_var in tvars:
            tclip(new_var, trange[0], trange[1], suffix='')

    return tvars
Ejemplo n.º 15
0
def load(trange=['2020-06-01', '2020-06-02'], 
         instrument='mag',
         datatype='rtn-normal', 
         mode=None,
         level='l2', 
         suffix='', 
         get_support_data=False, 
         varformat=None,
         varnames=[],
         downloadonly=False,
         notplot=False,
         no_update=False,
         time_clip=False):
    """
    This function loads data from the Solar Orbiter mission; this function is not meant 
    to be called directly; instead, see the wrappers:
        pyspedas.solo.mag
        pyspedas.solo.epd
        pyspedas.solo.rpw
        pyspedas.solo.swa

    """

    # Defaults for L2, L3 data
    science_or_low_latency = 'science'
    date_format = '%Y%m%d'
    cdf_version = '??'

    res = 24*3600.

    if level == 'll02':
        science_or_low_latency = 'low_latency'
        date_format = '%Y%m%dt%H%M??-*'
        cdf_version = '???'
        res = 60.0

    if instrument == 'mag':
        pathformat = instrument+'/'+science_or_low_latency+'/'+level+'/'+datatype+'/%Y/solo_'+level+'_'+instrument+'-'+datatype+'_'+date_format+'_v'+cdf_version+'.cdf'
    elif instrument == 'epd':
        pathformat = instrument+'/'+science_or_low_latency+'/'+level+'/'+datatype+'/'+mode+'/%Y/solo_'+level+'_'+instrument+'-'+datatype+'-'+mode+'_'+date_format+'_v'+cdf_version+'.cdf'
    elif instrument == 'rpw':
        pathformat = instrument+'/'+science_or_low_latency+'/'+level+'/'+datatype+'/%Y/solo_'+level+'_'+instrument+'-'+datatype+'_'+date_format+'_v'+cdf_version+'.cdf'
    elif instrument == 'swa':
        if level == 'l2' or level == 'll02':
            if datatype == 'pas-eflux' or datatype == 'pas-grnd-mom' or datatype == 'pas-vdf':
                pathformat = instrument+'/'+science_or_low_latency+'/'+level+'/'+datatype+'/%Y/solo_'+level+'_'+instrument+'-'+datatype+'_'+date_format+'_v'+cdf_version+'.cdf'
            else:
                date_format = '%Y%m%dt%H%M??-*'
                res = 60.0
                pathformat = instrument+'/'+science_or_low_latency+'/'+level+'/'+datatype+'/%Y/solo_'+level+'_'+instrument+'-'+datatype+'_'+date_format+'_v'+cdf_version+'.cdf'
        elif level == 'l1':
            if datatype == 'his-pha' or datatype == 'his-sensorrates' or datatype == 'pas-3d' or datatype == 'pas-cal' or datatype == 'pas-mom':
                pathformat = instrument+'/'+science_or_low_latency+'/'+level+'/'+datatype+'/%Y/solo_'+level+'_'+instrument+'-'+datatype+'_'+date_format+'_v'+cdf_version+'.cdf'
            else:
                date_format = '%Y%m%dt%H%M??-*'
                res = 60.0
                pathformat = instrument+'/'+science_or_low_latency+'/'+level+'/'+datatype+'/%Y/solo_'+level+'_'+instrument+'-'+datatype+'_'+date_format+'_v'+cdf_version+'.cdf'

    # find the full remote path names using the trange
    remote_names = dailynames(file_format=pathformat, trange=trange, res=res)

    out_files = []

    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)

    out_files = sorted(out_files)

    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)
    
    if notplot:
        return tvars

    if time_clip:
        for new_var in tvars:
            tclip(new_var, trange[0], trange[1], suffix='')

    return tvars
Ejemplo n.º 16
0
def load(trange=['2004-11-5', '2004-11-6'],
         instrument='lena', 
         datatype='k0', 
         suffix='', 
         get_support_data=False, 
         varformat=None,
         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
    
    """

    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)
    if files is not None:
        for file in files:
            out_files.append(file)

    out_files = sorted(out_files)

    if downloadonly:
        return out_files

    tvars = cdf_to_tplot(out_files, suffix=suffix, merge=True, get_support_data=get_support_data, varformat=varformat, notplot=notplot)
    
    if notplot:
        return tvars

    if time_clip:
        for new_var in tvars:
            tclip(new_var, trange[0], trange[1], suffix='')

    return tvars
Ejemplo n.º 17
0
def load(
        trange=['2018-11-5', '2018-11-6'],
        probe='a',
        instrument='emfisis',
        level='l3',
        datatype='magnetometer',
        suffix='',
        cadence='4sec',  # for EMFISIS mag data
        coord='sm',  # for EMFISIS mag data
        wavetype='waveform',  # for EMFISIS waveform data
        rel='rel04',  # for ECT data
        get_support_data=False,
        varformat=None,
        varnames=[],
        downloadonly=False,
        notplot=False,
        no_update=False,
        time_clip=False):
    """
    This function loads Van Allen Probes (RBSP) data; this function is not meant 
    to be called directly; instead, see the wrappers:
        pyspedas.rbsp.emfisis
        pyspedas.rbsp.rbspice
        pyspedas.rbsp.efw
        pyspedas.rbsp.mageis
        pyspedas.rbsp.hope
        pyspedas.rbsp.rept
        pyspedas.rbsp.rps
    
    """

    if not isinstance(probe, list):
        probe = [probe]

    out_files = []

    for prb in probe:
        if instrument == 'emfisis':
            if datatype == 'density' or datatype == 'housekeeping' or datatype == 'wna-survey':
                pathformat = 'rbsp' + prb + '/' + level + '/' + instrument + '/' + datatype + '/%Y/rbsp-' + prb + '_' + datatype + '_' + instrument + '-' + level + '_%Y%m%d_v*.cdf'
            elif datatype == 'wfr' or datatype == 'hfr':
                pathformat = 'rbsp' + prb + '/' + level + '/' + instrument + '/' + datatype + '/' + wavetype + '/%Y/rbsp-' + prb + '_' + datatype + '-' + wavetype + '_' + instrument + '-' + level + '_%Y%m%d*_v*.cdf'
            else:
                if level == 'l2' and datatype == 'magnetometer':
                    pathformat = 'rbsp' + prb + '/' + level + '/' + instrument + '/' + datatype + '/uvw/%Y/rbsp-' + prb + '_' + datatype + '_uvw_' + instrument + '-' + level + '_%Y%m%d*_v*.cdf'
                else:
                    pathformat = 'rbsp' + prb + '/' + level + '/' + instrument + '/' + datatype + '/' + cadence + '/' + coord + '/%Y/rbsp-' + prb + '_' + datatype + '_' + cadence + '-' + coord + '_' + instrument + '-' + level + '_%Y%m%d_v*.cdf'
        elif instrument == 'rbspice':
            pathformat = 'rbsp' + prb + '/' + level + '/' + instrument + '/' + datatype + '/%Y/rbsp-' + prb + '-' + instrument + '_lev-' + str(
                level[-1]) + '?' + datatype + '_%Y%m%d_v*.cdf'
        elif instrument == 'efw':
            if level == 'l3':
                pathformat = 'rbsp' + prb + '/' + level + '/' + instrument + '/%Y/rbsp' + prb + '_' + instrument + '-' + level + '_%Y%m%d_v??.cdf'
            else:
                pathformat = 'rbsp' + prb + '/' + level + '/' + instrument + '/' + datatype + '/%Y/rbsp' + prb + '_' + instrument + '-' + level + '_' + datatype + '_%Y%m%d_v??.cdf'
        elif instrument == 'mageis':
            pathformat = 'rbsp' + prb + '/' + level + '/ect/' + instrument + '/sectors/' + rel + '/%Y/rbsp' + prb + '_' + rel + '_ect-mageis-' + level + '_%Y%m%d_v*.cdf'
        elif instrument == 'hope':
            if datatype == 'moments':
                pathformat = 'rbsp' + prb + '/' + level + '/ect/' + instrument + '/' + datatype + '/' + rel + '/%Y/rbsp' + prb + '_' + rel + '_ect-hope-mom-' + level + '_%Y%m%d_v*.cdf'
            elif datatype == 'pitchangle':
                pathformat = 'rbsp' + prb + '/' + level + '/ect/' + instrument + '/' + datatype + '/' + rel + '/%Y/rbsp' + prb + '_' + rel + '_ect-hope-pa-' + level + '_%Y%m%d_v*.cdf'
            elif datatype == 'spinaverage':
                pathformat = 'rbsp' + prb + '/' + level + '/ect/' + instrument + '/' + datatype + '/' + rel + '/%Y/rbsp' + prb + '_' + rel + '_ect-hope-sci-' + level + 'sa_%Y%m%d_v*.cdf'
        elif instrument == 'rept':
            pathformat = 'rbsp' + prb + '/' + level + '/ect/' + instrument + '/sectors/' + rel + '/%Y/rbsp' + prb + '_' + rel + '_ect-rept-sci-' + level + '_%Y%m%d_v*.cdf'
        elif instrument == 'rps':
            if datatype == 'rps-1min':
                pathformat = 'rbsp' + prb + '/' + level + '/rps/psbr-rps-1min/%Y/rbsp' + prb + '_' + level + '-1min_psbr-rps_%Y%m%d_v*.cdf'
            elif datatype == 'rps':
                pathformat = 'rbsp' + prb + '/' + level + '/rps/psbr-rps/%Y/rbsp' + prb + '_' + level + '_psbr-rps_%Y%m%d_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=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)

    out_files = sorted(out_files)

    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)

    if notplot:
        return tvars

    if time_clip:
        for new_var in tvars:
            tclip(new_var, trange[0], trange[1], suffix='')

    return tvars
Ejemplo n.º 18
0
def load(trange=['2013-11-5', '2013-11-6'],
         probe='15',
         instrument='fgm',
         datatype='1min',
         suffix='',
         downloadonly=False,
         no_update=False,
         time_clip=False):
    """
    This function loads data from the GOES mission; this function is not meant 
    to be called directly; instead, see the wrappers:
        pyspedas.goes.fgm

    """

    if not isinstance(probe, list):
        probe = [probe]

    fullavgpath = ['full', 'avg']
    goes_path_dir = fullavgpath[datatype == '1min' or datatype == '5min']

    for prb in probe:
        remote_path = goes_path_dir + '/%Y/%m/goes' + str(prb) + '/netcdf/'

        if instrument == 'fgm':
            if datatype == '512ms':  # full, unaveraged data
                pathformat = remote_path + 'g' + str(
                    prb) + '_magneto_512ms_%Y%m%d_%Y%m%d.nc'
            elif datatype == '1min':  # 1 min averages
                pathformat = remote_path + 'g' + str(
                    prb) + '_magneto_1m_%Y%m01_%Y%m??.nc'
            elif datatype == '5min':  # 5 min averages
                pathformat = remote_path + 'g' + str(
                    prb) + '_magneto_5m_%Y%m01_%Y%m??.nc'

        # 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)
        if files is not None:
            for file in files:
                out_files.append(file)

    out_files = sorted(out_files)

    if downloadonly:
        return out_files

    tvars = netcdf_to_tplot(out_files,
                            suffix=suffix,
                            merge=True,
                            time='time_tag')

    if time_clip:
        for new_var in tvars:
            tclip(new_var, trange[0], trange[1], suffix='')

    return tvars
Ejemplo n.º 19
0
def load(trange=['2018-11-5', '2018-11-6'], 
         instrument='fields', 
         datatype='mag_rtn', 
         level='l2',
         suffix='', 
         get_support_data=False, 
         varformat=None,
         varnames=[],
         downloadonly=False,
         notplot=False,
         no_update=False,
         time_clip=False):
    """
    This function loads Parker Solar Probe data into tplot variables; this function is not 
    meant to be called directly; instead, see the wrappers: 
        psp.fields: FIELDS data
        psp.spc: Solar Probe Cup data
        psp.spe: SWEAP/SPAN-e data
        psp.spi: SWEAP/SPAN-i data
        psp.epihi: ISoIS/EPI-Hi data
        psp.epilo: ISoIS/EPI-Lo data
        psp.epi ISoIS/EPI (merged Hi-Lo) data
    
    """

    file_resolution = 24*3600.

    if instrument == 'fields':
        pathformat = instrument + '/' + level + '/' + datatype + '/%Y/psp_fld_' + level + '_' + datatype + '_%Y%m%d%H_v??.cdf'
        file_resolution = 6*3600.
    elif instrument == 'spc':
        pathformat = 'sweap/spc/' + level + '/' + datatype + '/%Y/psp_swp_spc_' + datatype + '_%Y%m%d_v??.cdf'
    elif instrument == 'spe':
        pathformat = 'sweap/spe/' + level + '/' + datatype + '/%Y/psp_swp_sp?_*_%Y%m%d_v??.cdf'
    elif instrument == 'spi':
        pathformat = 'sweap/spi/' + level + '/' + datatype + '/%Y/psp_swp_spi_*_%Y%m%d_v??.cdf'
    elif instrument == 'epihi':
        pathformat = 'isois/epihi/' + level + '/' + datatype + '/%Y/psp_isois-epihi_' + level + '*_%Y%m%d_v??.cdf'
    elif instrument == 'epilo':
        pathformat = 'isois/epilo/' + level + '/' + datatype + '/%Y/psp_isois-epilo_' + level + '*_%Y%m%d_v??.cdf'
    elif instrument == 'epi':
        pathformat = 'isois/merged/' + level + '/' + datatype + '/%Y/psp_isois_' + level + '-' + datatype + '_%Y%m%d_v??.cdf'

    # find the full remote path names using the trange
    remote_names = dailynames(file_format=pathformat, trange=trange, res=file_resolution)

    out_files = []

    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)

    out_files = sorted(out_files)

    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)

    if notplot:
        return tvars

    if time_clip:
        for new_var in tvars:
            tclip(new_var, trange[0], trange[1], suffix='')

    return tvars
Ejemplo n.º 20
0
 def test_local_file(self):
     # specifying local_file changes the local file name
     files = download(local_file='psp_data.cdf', remote_file='https://spdf.gsfc.nasa.gov/pub/data/psp/sweap/spc/l3/l3i/2019/psp_swp_spc_l3i_20190401_v01.cdf')
     self.assertTrue(len(files) == 1)
     self.assertTrue(files[0] == os.path.join(os.getcwd(), 'psp_data.cdf'))
Ejemplo n.º 21
0
import pyspedas
import pytplot
import numpy as np
from pyspedas.themis.spacecraft.fields.fit import cal_fit
from pyspedas.utilities.download import download
from pyspedas.themis.config import CONFIG

# Download tplot files
remote_server = 'https://spedas.org/'
remote_name = 'testfiles/cal_fit.tplot'
calfile = download(remote_file=remote_name,
                   remote_path=remote_server,
                   local_path=CONFIG['local_data_dir'],
                   no_download=False)

remote_name = 'testfiles/tha_efs_no_cal.tplot'
nocalfile = download(remote_file=remote_name,
                     remote_path=remote_server,
                     local_path=CONFIG['local_data_dir'],
                     no_download=False)

# Load validation variables
filename = calfile[0]
pytplot.tplot_restore(filename)
tha_fit_idl = pytplot.get_data('tha_fit')
tha_fgs_idl = pytplot.get_data('tha_fgs')
tha_fgs_sigma_idl = pytplot.get_data('tha_fgs_sigma')
tha_fit_bfit_idl = pytplot.get_data('tha_fit_bfit')
tha_fit_efit_idl = pytplot.get_data('tha_fit_efit')
tha_efs_idl = pytplot.get_data('tha_efs')
tha_efs_sigma_idl = pytplot.get_data('tha_efs_sigma')
Ejemplo n.º 22
0
def load(trange=['2013-11-5', '2013-11-6'], 
         probe='a',
         instrument='mag',
         level='l2',
         datatype='8hz',
         coord='RTN',
         suffix='', 
         get_support_data=False, 
         varformat=None,
         downloadonly=False,
         notplot=False,
         no_update=False,
         time_clip=False):
    """
    This function loads data from the STEREO mission; this function is not meant 
    to be called directly; instead, see the wrappers:
        pyspedas.stereo.mag
        pyspedas.stereo.plastic

    """

    out_files = []

    if not isinstance(probe, list):
        probe = [probe]

    if datatype == '32hz':
        burst = 'B'
    else:
        burst = ''

    for prb in probe:
        if prb == 'a':
            direction = 'ahead'
        elif prb == 'b':
            direction = 'behind'

        if instrument == 'mag':
            pathformat = 'impact/level1/'+direction+'/mag/'+coord+'/%Y/%m/ST'+prb.upper()+'_L1_MAG'+burst+'_'+coord+'_%Y%m%d_V??.cdf'
        elif instrument == 'plastic':
            CONFIG['remote_data_dir'] = 'http://stereo-ssc.nascom.nasa.gov/data/ins_data/'
            if level == 'l2':
                pathformat = 'plastic/level2/Protons/Derived_from_1D_Maxwellian/'+direction+'/'+datatype+'/%Y/ST'+prb.upper()+'_L2_PLA_1DMax_'+datatype+'_%Y%m%d_V??.cdf'

        # find the full remote path names using the trange
        remote_names = dailynames(file_format=pathformat, trange=trange)

        for remote_file in remote_names:
            files = download(remote_file=remote_file, 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)

    out_files = sorted(out_files)

    if downloadonly:
        return out_files

    tvars = cdf_to_tplot(out_files, suffix=suffix, merge=True, get_support_data=get_support_data, varformat=varformat, notplot=notplot)
    
    if notplot:
        return tvars

    if time_clip:
        for new_var in tvars:
            tclip(new_var, trange[0], trange[1], suffix='')

    return tvars
Ejemplo n.º 23
0
 def test_local_path(self):
     # specifying local_path changes the local data directory
     files = download(local_path='psp_data/spc/l3', remote_file='https://spdf.gsfc.nasa.gov/pub/data/psp/sweap/spc/l3/l3i/2019/psp_swp_spc_l3i_20190401_v01.cdf')
     self.assertTrue(len(files) == 1)
     self.assertTrue(files[0] == os.path.join('psp_data/spc/l3', 'psp_swp_spc_l3i_20190401_v01.cdf'))
Ejemplo n.º 24
0
def mms_part_des_photoelectrons(dist_var):
    """
    Loads and returns the FPI/DES photoelectron model based on stepper ID

    Input
    ----------
        dist_var: str
            tplot variable containing DES distribution data

    Notes
    ----------
        For more information on the model, see:
        https://agupubs.onlinelibrary.wiley.com/doi/full/10.1002/2017JA024518

    Returns
    ----------
        Dictionary containing the photoelectron model
    """
    data = get_data(dist_var)

    if data is None:
        logging.error('Problem reading DES distribution variable')
        return

    # get the metadata for the 'energy_table_name' from the global attributes
    metadata = get_data(dist_var, metadata=True)

    try:
        table_name = metadata['CDF']['GATT']['Energy_table_name']
    except KeyError:
        logging.error('Problem extracting the energy table name from the DF metadata')
        return

    stepper_id = table_name.replace('.txt', '').split('energies_des_')[-1]

    # we'll need the data rate
    data_rate = dist_var.split('_')[-1]

    # download the model file from the SDC
    pe_model = download(
        last_version=True,
        remote_path='https://lasp.colorado.edu/mms/sdc/public/data/models/fpi/',
        remote_file='mms_fpi_'+data_rate+'_l2_des-bgdist_v?.?.?_p'+stepper_id+'.cdf',
        local_path=os.path.join(CONFIG['local_data_dir'], 'mms'+os.path.sep+'sdc'+os.path.sep+'public'+os.path.sep+'data'+os.path.sep+'models'+os.path.sep+'fpi'+os.path.sep+''))

    if len(pe_model) != 1:
        logging.error('Problem downloading DES model from the SDC')
        return

    model_vars = cdf_to_tplot(pe_model[0], get_support_data=True)

    if data_rate == 'fast':
        bg_dist = get_data('mms_des_bgdist_fast')
        nphoto = get_data('mms_des_numberdensity_fast')
        return {'bg_dist': bg_dist, 'n': nphoto}
    elif data_rate == 'brst':
        bg_dist_0 = get_data('mms_des_bgdist_p0_brst')
        bg_dist_1 = get_data('mms_des_bgdist_p1_brst')
        nphoto_0 = get_data('mms_des_numberdensity_p0_brst')
        nphoto_1 = get_data('mms_des_numberdensity_p1_brst')
        return {'bgdist_p0': bg_dist_0, 
                'bgdist_p1': bg_dist_1, 
                'n_0': nphoto_0, 
                'n_1': nphoto_1}

    # shouldn't get here
    logging.error('Error: something went wrong with the photoelectron model')
    return
Ejemplo n.º 25
0
 def test_remote_path(self):
     # only specifying remote_path saves the files to the current working directory
     files = download(remote_path='https://spdf.gsfc.nasa.gov/pub/data/psp/sweap/spc/l3/l3i/2019/psp_swp_spc_l3i_20190401_v01.cdf')
     self.assertTrue(len(files) == 1)
     self.assertTrue(files[0] == os.path.join(os.getcwd(), 'psp_swp_spc_l3i_20190401_v01.cdf'))
Ejemplo n.º 26
0
def load(trange=['1997-01-03', '1997-01-04'],
         instrument='mfe',
         datatype='k0',
         suffix='',
         get_support_data=False,
         varformat=None,
         varnames=[],
         downloadonly=False,
         notplot=False,
         no_update=False,
         time_clip=False):
    """
    This function loads data from the Polar mission; this function is not meant 
    to be called directly; instead, see the wrappera:
        pyspedas.polar.mfe
        pyspedas.polar.efi
        pyspedas.polar.pwi
        pyspedas.polar.hydra
        pyspedas.polar.tide
        pyspedas.polar.timas
        pyspedas.polar.cammice
        pyspedas.polar.ceppad
        pyspedas.polar.uvi
        pyspedas.polar.vis
        pyspedas.polar.pixie
        pyspedas.polar.orbit

    """

    if instrument == 'mfe':
        pathformat = instrument + '/' + instrument + '_' + datatype + '/%Y/po_' + datatype + '_' + instrument + '_%Y%m%d_v??.cdf'
    elif instrument == 'efi':
        pathformat = instrument + '/' + instrument + '_' + datatype + '/%Y/po_' + datatype + '_' + instrument + '_%Y%m%d_v??.cdf'
    elif instrument == 'pwi':
        pathformat = instrument + '/' + instrument + '_' + datatype + '/%Y/po_' + datatype + '_' + instrument + '_%Y%m%d_v??.cdf'
    elif instrument == 'hydra':
        pathformat = instrument + '/' + instrument + '_' + datatype + '/%Y/po_' + datatype + '_hyd_%Y%m%d_v??.cdf'
    elif instrument == 'tide':
        pathformat = instrument + '/' + instrument + '_' + datatype + '/%Y/po_' + datatype + '_tid_%Y%m%d_v??.cdf'
    elif instrument == 'timas':
        pathformat = instrument + '/' + instrument + '_' + datatype + '/%Y/po_' + datatype + '_tim_%Y%m%d_v??.cdf'
    elif instrument == 'cammice':
        pathformat = instrument + '/' + instrument + '_' + datatype + '/%Y/po_' + datatype + '_cam_%Y%m%d_v??.cdf'
    elif instrument == 'ceppad':
        pathformat = instrument + '/' + instrument + '_' + datatype + '/%Y/po_' + datatype + '_cep_%Y%m%d_v??.cdf'
    elif instrument == 'uvi':
        pathformat = instrument + '/' + instrument + '_' + datatype + '/%Y/po_' + datatype + '_' + instrument + '_%Y%m%d_v??.cdf'
    elif instrument == 'vis':
        pathformat = instrument + '/' + instrument + '_' + datatype + '/%Y/po_' + datatype + '_' + instrument + '_%Y%m%d_v??.cdf'
    elif instrument == 'pixie':
        pathformat = instrument + '/' + instrument + '_' + datatype + '/%Y/po_' + datatype + '_pix_%Y%m%d_v??.cdf'
    elif instrument == 'spha':
        pathformat = 'orbit/' + instrument + '_' + datatype + '/%Y/po_' + datatype + '_' + instrument + '_%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)
    if files is not None:
        for file in files:
            out_files.append(file)

    out_files = sorted(out_files)

    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)

    if notplot:
        return tvars

    if time_clip:
        for new_var in tvars:
            tclip(new_var, trange[0], trange[1], suffix='')

    return tvars
Ejemplo n.º 27
0
def load(trange=['2017-03-27', '2017-03-28'],
         instrument='mgf',
         datatype='8sec',
         mode=None,
         site=None,
         level='l2',
         suffix='',
         get_support_data=False,
         varformat=None,
         varnames=[],
         downloadonly=False,
         notplot=False,
         no_update=False,
         uname=None,
         passwd=None,
         time_clip=False):
    """
    This function is not meant to be called directly; please see the instrument specific wrappers:
        pyspedas.erg.mgf()
        pyspedas.erg.hep()
        pyspedas.erg.orb()
        pyspedas.erg.lepe()
        pyspedas.erg.lepi()
        pyspedas.erg.mepe()
        pyspedas.erg.mepi()
        pyspedas.erg.pwe_ofa()
        pyspedas.erg.pwe_efd()
        pyspedas.erg.pwe_hfa()
        pyspedas.erg.xep()
    """

    prefix = 'erg_' + instrument + '_' + level + '_'
    file_res = 24 * 3600.

    if instrument == 'mgf':
        pathformat = 'satellite/erg/' + instrument + '/' + level + '/' + datatype + '/%Y/%m/erg_' + instrument + '_' + level + '_' + datatype + '_%Y%m%d_v??.??.cdf'
    elif instrument == 'hep':
        pathformat = 'satellite/erg/' + instrument + '/' + level + '/' + datatype + '/%Y/%m/erg_' + instrument + '_' + level + '_' + datatype + '_%Y%m%d_v??_??.cdf'
    elif instrument == 'orb':
        pathformat = 'satellite/erg/' + instrument + '/' + level + '/opq/%Y/%m/erg_' + instrument + '_' + level + '_op_%Y%m%d_v??.cdf'
    elif instrument == 'lepe':
        pathformat = 'satellite/erg/' + instrument + '/' + level + '/' + datatype + '/%Y/%m/erg_' + instrument + '_' + level + '_' + datatype + '_%Y%m%d_v??_??.cdf'
    elif instrument == 'lepi':
        pathformat = 'satellite/erg/' + instrument + '/' + level + '/' + datatype + '/%Y/%m/erg_' + instrument + '_' + level + '_' + datatype + '_%Y%m%d_v??_??.cdf'
    elif instrument == 'mepe':
        pathformat = 'satellite/erg/' + instrument + '/' + level + '/' + datatype + '/%Y/%m/erg_' + instrument + '_' + level + '_' + datatype + '_%Y%m%d_v??_??.cdf'
    elif instrument == 'mepi':
        pathformat = 'satellite/erg/' + instrument + '/' + level + '/' + datatype + '/%Y/%m/erg_' + instrument + '_' + level + '_' + datatype + '_%Y%m%d_v??_??.cdf'
    elif instrument == 'pwe_ofa':
        pathformat = 'satellite/erg/pwe/ofa/' + level + '/' + datatype + '/%Y/%m/erg_' + instrument + '_' + level + '_' + datatype + '_%Y%m%d_v??_??.cdf'
    elif instrument == 'pwe_efd':
        pathformat = 'satellite/erg/pwe/efd/' + level + '/' + datatype + '/%Y/%m/erg_' + instrument + '_' + level + '_' + datatype + '_%Y%m%d_v??_??.cdf'
    elif instrument == 'pwe_hfa':
        pathformat = 'satellite/erg/pwe/hfa/' + level + '/' + datatype + '/' + mode + '/%Y/%m/erg_' + instrument + '_' + level + '_' + datatype + '_' + mode + '_%Y%m%d_v??_??.cdf'
    elif instrument == 'xep':
        pathformat = 'satellite/erg/' + instrument + '/' + level + '/' + datatype + '/%Y/%m/erg_' + instrument + '_' + level + '_' + datatype + '_%Y%m%d_v??_??.cdf'

    # find the full remote path names using the trange
    remote_names = dailynames(file_format=pathformat,
                              trange=trange,
                              res=file_res)

    out_files = []

    files = download(remote_file=remote_names,
                     remote_path=CONFIG['remote_data_dir'],
                     local_path=CONFIG['local_data_dir'],
                     no_download=no_update,
                     last_version=True,
                     username=uname,
                     password=passwd)
    if files is not None:
        for file in files:
            out_files.append(file)

    out_files = sorted(out_files)

    if downloadonly:
        return out_files

    tvars = cdf_to_tplot(out_files,
                         prefix=prefix,
                         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='')

    return tvars
Ejemplo n.º 28
0
def load(trange=['2013-11-5', '2013-11-6'],
         instrument='fgm',
         datatype='k0',
         suffix='',
         get_support_data=False,
         varformat=None,
         downloadonly=False,
         notplot=False,
         no_update=False,
         varnames=[],
         time_clip=False):
    """
    This function loads data from the ACE mission; this function is not meant 
    to be called directly; instead, see the wrappers:
        pyspedas.ace.mfi
        pyspedas.ace.swe
        pyspedas.ace.epam
        pyspedas.ace.cris
        pyspedas.ace.sis
        pyspedas.ace.uleis
        pyspedas.ace.sepica
        pyspedas.ace.swics

    """

    if instrument == 'fgm':
        pathformat = 'mag/level_2_cdaweb/mfi_' + datatype + '/%Y/ac_' + datatype + '_mfi_%Y%m%d_v??.cdf'
    elif instrument == 'swe':
        pathformat = 'swepam/level_2_cdaweb/swe_' + datatype + '/%Y/ac_' + datatype + '_swe_%Y%m%d_v??.cdf'
    elif instrument == 'epm':
        pathformat = 'epam/level_2_cdaweb/epm_' + datatype + '/%Y/ac_' + datatype + '_epm_%Y%m%d_v??.cdf'
    elif instrument == 'cris':
        pathformat = 'cris/level_2_cdaweb/cris_' + datatype + '/%Y/ac_' + datatype + '_cris_%Y%m%d_v??.cdf'
    elif instrument == 'sis':
        pathformat = 'sis/level_2_cdaweb/sis_' + datatype + '/%Y/ac_' + datatype + '_sis_%Y%m%d_v??.cdf'
    elif instrument == 'ule':
        pathformat = 'uleis/level_2_cdaweb/ule_' + datatype + '/%Y/ac_' + datatype + '_ule_%Y%m%d_v??.cdf'
    elif instrument == 'sep':
        pathformat = 'sepica/level_2_cdaweb/sep_' + datatype + '/%Y/ac_' + datatype + '_sep_%Y%m%d_v??.cdf'
    elif instrument == 'swics':
        filename_dtype = datatype.split('_')[1] + '_' + datatype.split('_')[0]
        pathformat = 'swics/level_2_cdaweb/' + datatype + '/%Y/ac_' + filename_dtype + '_%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)
    if files is not None:
        for file in files:
            out_files.append(file)

    out_files = sorted(out_files)

    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)

    if notplot:
        return tvars

    if time_clip:
        for new_var in tvars:
            tclip(new_var, trange[0], trange[1], suffix='')

    return tvars
Ejemplo n.º 29
0
def load(trange=['2013-11-5', '2013-11-6'],
         instrument='fgm',
         datatype='h0',
         suffix='',
         get_support_data=False,
         varformat=None,
         varnames=[],
         downloadonly=False,
         notplot=False,
         no_update=False,
         time_clip=False):
    """
    This function loads data from the WIND mission; this function is not meant 
    to be called directly; instead, see the wrappers:
        pyspedas.wind.mfi
        pyspedas.wind.swe
        pyspedas.wind.sms
        pyspedas.wind.threedp
        pyspedas.wind.waves
        pyspedas.wind.orbit

    """

    if instrument == 'fgm':
        pathformat = 'mfi/mfi_' + datatype + '/%Y/wi_' + datatype + '_mfi_%Y%m%d_v??.cdf'
    elif instrument == 'swe':
        pathformat = 'swe/swe_' + datatype + '/%Y/wi_' + datatype + '_swe_%Y%m%d_v??.cdf'
    elif instrument == 'sms':
        pathformat = 'sms/' + datatype + '/sms_' + datatype + '/%Y/wi_' + datatype + '_sms_%Y%m%d_v??.cdf'
    elif instrument == 'waves':
        pathformat = 'waves/wav_' + datatype + '/%Y/wi_' + datatype + '_wav_%Y%m%d_v??.cdf'
    elif instrument == 'orbit':
        pathformat = 'orbit/' + datatype + '/%Y/wi_' + datatype.split(
            '_')[1] + '_' + datatype.split('_')[0] + '_%Y%m%d_v??.cdf'
    elif instrument == '3dp':
        if datatype == '3dp_emfits_e0':
            pathformat = '3dp/' + datatype + '/%Y/wi_' + datatype.split(
                '_')[1] + '_' + datatype.split('_')[2] + '_' + datatype.split(
                    '_')[0] + '_%Y%m%d_v??.cdf'
        else:
            pathformat = '3dp/' + datatype + '/%Y/wi_' + datatype.split(
                '_')[1] + '_' + datatype.split('_')[0] + '_%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,
                     last_version=True)
    if files is not None:
        for file in files:
            out_files.append(file)

    out_files = sorted(out_files)

    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)

    if notplot:
        return tvars

    if time_clip:
        for new_var in tvars:
            tclip(new_var, trange[0], trange[1], suffix='')

    return tvars
Ejemplo n.º 30
0
def load(trange=['2018-11-5', '2018-11-6'],
         probe='1',
         instrument='lad',
         datatype='',
         suffix='',
         get_support_data=False,
         varformat=None,
         downloadonly=False,
         notplot=False,
         no_update=False,
         time_clip=False):
    """
    This function loads TWINS data; this function is not meant 
    to be called directly; instead, see the wrappers:
        pyspedas.twins.lad
        pyspedas.twins.ephemeris
        pyspedas.twins.imager

    """

    if not isinstance(probe, list):
        probe = [probe]

    probe = [str(prb) for prb in probe]

    out_files = []

    for prb in probe:
        if instrument == 'lad':
            pathformat = 'twins' + prb + '/' + instrument + '/%Y/twins' + prb + '_l1_lad_%Y%m%d_v??.cdf'
        elif instrument == 'imager':
            pathformat = 'twins' + prb + '/' + instrument + '/%Y/twins' + prb + '_l1_imager_%Y%m%d??_v??.cdf'
        elif instrument == 'ephemeris':
            pathformat = 'twins' + prb + '/' + instrument + '/' + datatype + '/%Y/twins' + prb + '_' + datatype + '_def_%Y%m%d_v??.cdf'

        # find the full remote path names using the trange
        remote_names = dailynames(file_format=pathformat, trange=trange)

        for remote_file in remote_names:
            files = download(remote_file=remote_file,
                             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)

    out_files = sorted(out_files)

    if downloadonly:
        return out_files

    tvars = cdf_to_tplot(out_files,
                         suffix=suffix,
                         merge=True,
                         get_support_data=get_support_data,
                         varformat=varformat,
                         notplot=notplot)

    if notplot:
        return tvars

    if time_clip:
        for new_var in tvars:
            tclip(new_var, trange[0], trange[1], suffix='')

    return tvars