Esempio n. 1
0
def themis_load(dates,
                probes,
                instruments,
                level,
                downloadonly=False,
                varformat=None,
                get_support_data=False,
                prefix='',
                suffix=''):
    """Loads themis data into pytplot variables"""

    file_list = themis_filename(dates, probes, instruments, level)
    # print(file_list)
    count = 0
    dcount = 0

    for remotef, localf in file_list:
        count += 1
        resp, err, localfile = pyspedas.download_files(remotef, localf)
        if resp:
            print(str(count) + '. File was downloaded. Location: ' + localfile)
            dcount += 1
            if not downloadonly:
                try:
                    cdfvars = pyspedas.cdf_to_tplot(localfile, varformat,
                                                    get_support_data, prefix,
                                                    suffix, False, True)

                except TypeError as e:
                    msg = "cdf_to_tplot could not load " + localfile
                    + "\nError:\n" + str(e)
                    print(msg)

        else:
            print(
                str(count) + '. There was a problem. Could not download \
                  file: ' + remotef)
            print(err)

    if len(dates) == 2:
        pyspedas.time_clip(cdfvars, dates[0], dates[1], cdfvars)

    print('Downloaded ' + str(dcount) + ' files.')
    print('tplot variables:')
    print(pyspedas.tplot_names())
Esempio n. 2
0
def gmag_load(dates,
              stations,
              group=None,
              downloadonly=False,
              varformat=None,
              get_support_data=False,
              prefix='',
              suffix=''):
    """Loads themis data into pytplot variables"""

    if group is not None:
        stations = gmag_list(group)

    file_list = gmag_filename(dates, stations)

    count = 0
    dcount = 0
    for remotef, localf in file_list:
        count += 1
        resp, err, locafile = pyspedas.download_files(remotef, localf)
        if resp:
            print(str(count) + '. File was downloaded. Location: ' + locafile)
            dcount += 1
            if not downloadonly:
                try:
                    testcdf = pyspedas.cdf_to_tplot(locafile, varformat,
                                                    get_support_data, prefix,
                                                    suffix, False, True)
                    print(testcdf)
                except TypeError as e:
                    msg = "cdf_to_tplot could not load " + locafile
                    + "\nError:\n" + str(e)
                    print(msg)

        else:
            print(
                str(count) + '. There was a problem. Could not download \
                  file: ' + remotef)
            print(err)

    print('Downloaded ' + str(dcount) + ' files.')
    print('tplot variables:')
    print(pyspedas.tplot_names())