How to use the pysat.datetime function in pysat

To help you get started, we’ve selected a few pysat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pysat / pysat / pysat / instruments / pysat_testsmall.py View on Github external
def list_files(tag=None, sat_id=None, data_path=None, format_str=None):
    """Produce a fake list of files spanning a year"""

    index = pds.date_range(pysat.datetime(2008, 1, 1),
                           pysat.datetime(2010, 12, 31))
    names = [data_path + date.strftime('%D') + '.nofile' for date in index]
    return pysat.Series(names, index=index)
github pysat / pysat / pysat / instruments / superdarn_grdex.py View on Github external
import sys
import os
import functools

import pandas as pds
import numpy as np

import pysat

platform = 'superdarn'
name = 'grdex'
tags = {'north': '',
        'south': ''}
sat_ids = {'': ['north', 'south']}
_test_dates = {'': {'north': pysat.datetime(2009, 1, 1),
                   'south': pysat.datetime(2009, 1, 1)}}


def init(self):
    """Initializes the Instrument object with instrument specific values.

    Runs once upon instantiation.

    Parameters
    ----------
    self : pysat.Instrument
        This object

    Returns
    --------
    Void : (NoneType)
        Object modified in place.
github pysat / pysat / pysat / instruments / pysat_sgp4.py View on Github external
except NameError:
    basestring = str
import os

import pandas as pds
import numpy as np
import pysat

# pysat required parameters
platform = 'pysat'
name = 'sgp4'
# dictionary of data 'tags' and corresponding description
tags = {'': 'Satellite simulation data set'}
# dictionary of satellite IDs, list of corresponding tags
sat_ids = {'': ['']}
_test_dates = {'': {'': pysat.datetime(2018, 1, 1)}}


def init(self):
    """
    Adds custom calculations to orbit simulation.
    This routine is run once, and only once, upon instantiation.

    Adds quasi-dipole coordiantes, velocity calculation in ECEF coords,
    adds the attitude vectors of spacecraft assuming x is ram pointing and
    z is generally nadir, adds ionospheric parameters from the Interational
    Reference Ionosphere (IRI), as well as simulated winds from the
    Horiontal Wind Model (HWM).

    """

    self.custom.add(add_quasi_dipole_coordinates, 'modify')
github pysat / pysat / pysat / instruments / supermag_magnetometer.py View on Github external
import pandas as pds
import numpy as np
from os import path
import functools
import warnings

import pysat

platform = 'supermag'
name = 'magnetometer'
tags = {'indices': 'SMU and SML indices',
        '': 'magnetometer measurements',
        'all': 'magnetometer measurements and indices',
        'stations': 'magnetometer stations'}
sat_ids = {'': tags.keys()}
_test_dates = {'': {kk: pysat.datetime(2009, 1, 1) for kk in tags.keys()}}


def init(self):
    """Initializes the Instrument object with instrument specific values.

    Runs once upon instantiation.

    Parameters
    ----------
    self : pysat.Instrument
        This object

    Returns
    --------
    Void : (NoneType)
        Object modified in place.
github pysat / pysat / pysat / instruments / sw_f107.py View on Github external
year : (int)
        Year of data file (format changes based on date)
    outfile : (str)
        Output filename
    lines : (str)
        String containing all output data (result of 'read')

    Returns
    -------
    Void

    """

    # Parse text to get the date the prediction was generated
    date_str = lines.split(':Issued: ')[-1].split('\n')[0]
    date = pysat.datetime.strptime(date_str, '%H%M UT %d %b %Y')

    # get to the solar index data
    if year > 2000:
        raw_data = lines.split('#---------------------------------')[-1]
        raw_data = raw_data.split('\n')[1:-1]
        optical = True
    else:
        raw_data = lines.split('# ')[-1]
        raw_data = raw_data.split('\n')
        optical = False if raw_data[0].find('Not Available') or year == 1994 \
            else True
        istart = 7 if year < 2000 else 1
        raw_data = raw_data[istart:-1]

    # parse the data
    solar_times, data_dict = parse_daily_solar_data(raw_data, year, optical)
github pysat / pysat / pysat / instruments / cosmic2013_gps.py View on Github external
from scipy.io.netcdf import netcdf_file
import pandas as pds
import numpy as np
import pysat

platform = 'cosmic2013'
name = 'gps'
tags = {'ionprf': '',
        'sonprf': '',
        'wetprf': '',
        'atmprf': ''}
sat_ids = {'': ['ionprf', 'sonprf', 'wetprf', 'atmprf']}
test_dates = {'': {'ionprf': pysat.datetime(2008, 1, 1),
                   'sonprf': pysat.datetime(2008, 1, 1),
                   'wetprf': pysat.datetime(2008, 1, 1),
                   'atmprf': pysat.datetime(2008, 1, 1)}}


def list_files(tag=None, sat_id=None, data_path=None, format_str=None):
    """Return a Pandas Series of every file for chosen satellite data

    Parameters
    -----------
    tag : (string or NoneType)
        Denotes type of file to load.  Accepted types are '' and 'ascii'.
        If '' is specified, the primary data type (ascii) is loaded.
        (default=None)
    sat_id : (string or NoneType)
        Specifies the satellite ID for a constellation.  Not used.
        (default=None)
    data_path : (string or NoneType)
        Path to data directory.  If None is specified, the value previously
github pysat / pysat / pysat / instruments / omni_hro.py View on Github external
from __future__ import print_function
from __future__ import absolute_import

import functools
import numpy as np
import pandas as pds

import pysat
from .methods import nasa_cdaweb as cdw

platform = 'omni'
name = 'hro'
tags = {'1min': '1-minute time averaged data',
        '5min': '5-minute time averaged data'}
sat_ids = {'': ['5min']}
_test_dates = {'': {'1min': pysat.datetime(2009, 1, 1),
                   '5min': pysat.datetime(2009, 1, 1)}}

# support list files routine
# use the default CDAWeb method
fname1 = 'omni_hro_1min_{year:4d}{month:02d}{day:02d}_v01.cdf'
fname5 = 'omni_hro_5min_{year:4d}{month:02d}{day:02d}_v01.cdf'
supported_tags = {'': {'1min': fname1,
                       '5min': fname5}}
list_files = functools.partial(cdw.list_files,
                               supported_tags=supported_tags,
                               fake_daily_files_from_monthly=True)

# support load routine
# use the default CDAWeb method
load = functools.partial(cdw.load, fake_daily_files_from_monthly=True)
github pysat / pysat / pysat / instruments / erg_mepi.py View on Github external
import functools
import numpy as np
import sys
import pandas as pds
import pysat

# CDAWeb methods prewritten for pysat
from .methods import nasa_cdaweb as cdw

platform = 'erg'
name = 'mepi'

# dictionary of data 'tags' and corresponding description
tags = {'': 'omni flux data'}
sat_ids = {'': ['']}
test_dates = {'': {'': pysat.datetime(2017, 4, 1)}}

remote_site = 'https://ergsc.isee.nagoya-u.ac.jp'
fname = 'erg_mepi_l2_omniflux_{year:04d}{month:02d}{day:02d}_v01_00.cdf'
supported_tags = {'': {'': fname}}
# use the CDAWeb methods list files routine
# the command below presets some of the methods inputs, leaving
# those provided by pysat available when invoked
list_files = functools.partial(cdw.list_files,
                               supported_tags=supported_tags)

# use the default CDAWeb method
# no other information needs to be supplied here
# pysatCDF is used to load data
load = cdw.load
basic_tag = {'dir': '/data/ergsc/satellite/erg/mepi/l2/omniflux/',
             'remote_fname': '{year:4d}/{month:2d}/' + fname,
github pysat / pysat / pysat / instruments / jro_isr.py View on Github external
from .methods import madrigal as mad_meth
from .methods import nasa_cdaweb as cdw


platform = 'jro'
name = 'isr'
tags = {'drifts': 'Drifts and wind', 'drifts_ave': 'Averaged drifts',
        'oblique_stan': 'Standard Faraday rotation double-pulse',
        'oblique_rand': 'Randomized Faraday rotation double-pulse',
        'oblique_long': 'Long pulse Faraday rotation'}
sat_ids = {'': list(tags.keys())}
test_dates = {'': {'drifts': pysat.datetime(2010, 1, 19),
                   'drifts_ave': pysat.datetime(2010, 1, 19),
                   'oblique_stan': pysat.datetime(2010, 4, 19),
                   'oblique_rand': pysat.datetime(2000, 11, 9),
                   'oblique_long': pysat.datetime(2010, 4, 12)}}

# support list files routine
# use the default CDAWeb method
jro_fname1 = 'jro{year:4d}{month:02d}{day:02d}'
jro_fname2 = '.{version:03d}.hdf5'
supported_tags = {ss: {'drifts': jro_fname1 + "drifts" + jro_fname2,
                       'drifts_ave': jro_fname1 + "drifts_avg" + jro_fname2,
                       'oblique_stan': jro_fname1 + jro_fname2,
                       'oblique_rand': jro_fname1 + "?" + jro_fname2,
                       'oblique_long': jro_fname1 + "?" + jro_fname2}
                  for ss in sat_ids.keys()}
list_files = functools.partial(cdw.list_files,
                               supported_tags=supported_tags)

# madrigal tags
madrigal_inst_code = 10
github pysat / pysat / pysat / instruments / templates / template_cdaweb_instrument.py View on Github external
# Let pysat know if there are multiple satellite platforms supported
# by these routines
# define a dictionary keyed by satellite ID, each with a list of
# corresponding tags
# sat_ids = {'a':['L1', 'L0'], 'b':['L1', 'L2'], 'c':['L1', 'L3']}
sat_ids = {'': ['']}

# Define good days to download data for when pysat undergoes testing.
# format is outer dictionary has sat_id as the key
# each sat_id has a dictionary of test dates keyed by tag string
# _test_dates = {'a':{'L0':pysat.datetime(2019,1,1),
#                    'L1':pysat.datetime(2019,1,2)},
#               'b':{'L1':pysat.datetime(2019,3,1),
#                    'L2':pysat.datetime(2019,11,23),}}
_test_dates = {'': {'': pysat.datetime(2019, 1, 1)}}

# Additional information needs to be defined
# to support the CDAWeb list files routine
# We need to define a filename format string for every
# supported combination of sat_id and tag string
# fname1 = 'cnofs_vefi_bfield_1sec_{year:04d}{month:02d}{day:02d}_v05.cdf'
# fname2 = 'cnofs_vefi_acfield_1sec_{year:04d}{month:02d}{day:02d}_v05.cdf'
# supported_tags = {'sat1':{'tag1':fname1},
#                   'sat2':{'tag2':fname2}}
# you can use format keywords year, month, day, hour, min, sec,
# version and revision
# see code docstring for latest
fname = 'cnofs_vefi_bfield_1sec_{year:04d}{month:02d}{day:02d}_v05.cdf'
supported_tags = {'': {'': fname}}
# use the CDAWeb methods list files routine
# the command below presets some of the methods inputs, leaving