How to use the pysat.Instrument 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 / constellations / test_diff_small.py View on Github external
import pysat

"""
Creates a constellationfor testing difference with two small test instruments
"""

inst1 = pysat.Instrument('pysat', 'testsmall', clean_level='clean', tag='6000')
inst2 = pysat.Instrument('pysat', 'testsmall', clean_level='clean', tag='6000')
instruments = [inst1, inst2]
github pysat / pysat / test_ix.py View on Github external
# Test code for pandas ix deprecation tests
# Delete before merging pull request!

import pysat

date = pysat.datetime(2011,6,29)
ivm = pysat.Instrument(platform='cnofs', name='ivm',clean_level='none')
ivm.load(date=date)

# By name
print('input => Ni')
print(ivm['Ni'])
print('\n')

# Slicing by name
# print('input => zpos:zvel')
# print(ivm['zpos':'zvel'])
# print('\n')

# By position
print('input => 0, Ni')
print(ivm[0,'Ni'])
print('\n')
github pysat / pysat / tests / test_instrument.py View on Github external
def setup(self):
        reload(pysat.instruments.pysat_testing)
	'''Runs before every method to create a clean testing setup.'''
        self.testInst = pysat.Instrument('pysat', 'testing', '10', 'clean')
github pysat / pysat / tests / test_instrument.py View on Github external
def test_custom_instrument_load(self):
        '''
        Test if the correct day is being loaded (End-to-End), 
        with no instrument file but routines are passed.
        '''
        import pysat.instruments.pysat_testing as test
        testInst = pysat.Instrument(inst_module=test, tag='1000', clean_level='clean')
        testInst.load(2009,32)
        assert testInst.date == pds.datetime(2009,2,1)
github pysat / pysat / tests / test_instrument.py View on Github external
    @raises(AttributeError)
    def test_custom_instrument_load_2(self):
        '''
        Test if an exception is thrown correctly if there is no 
        instrument file and supplied routines are incomplete.
        '''
        import pysat.instruments.pysat_testing as test
        del test.list_files
        testIn = pysat.Instrument(inst_module=test, tag='1000', clean_level='clean')
        testIn.load(2009,1)
github pysat / pysat / pysat / constellations / test_add_opposite.py View on Github external
import pysat

"""
Creates an instrument used to test the constellation class's addition function.
The result of adding the dummy1 signals from this instrument should always be 0
"""

instruments = [pysat.Instrument('pysat', 'testadd1', clean_level='clean'),
               pysat.Instrument('pysat', 'testadd2', clean_level='clean')]
github pysat / pysat / demo / ssnl_occurrence_by_orbit.py View on Github external
the occurrent probability of an event occurring.
'''

import os
import pysat
import matplotlib.pyplot as plt
import pandas as pds
import numpy as np

# set the directory to save plots to
results_dir = ''

# select vefi dc magnetometer data, use longitude to determine where
# there are changes in the orbit (local time info not in file)
orbit_info = {'index': 'longitude', 'kind': 'longitude'}
vefi = pysat.Instrument(platform='cnofs', name='vefi', tag='dc_b',
                        clean_level=None, orbit_info=orbit_info)


# define functino to remove flagged values
def filter_vefi(inst):
    idx, = np.where(vefi['B_flag'] == 0)
    vefi.data = vefi.data.iloc[idx]
    return


vefi.custom.add(filter_vefi, 'modify')
# set limits on dates analysis will cover, inclusive
start = pds.datetime(2010, 5, 9)
stop = pds.datetime(2010, 5, 15)

# if there is no vefi dc magnetometer data on your system, then run command
github pysat / pysat / pysat / instruments / methods / sw.py View on Github external
start = min(stimes) if len(stimes) > 0 else None

    if stop is None:
        stimes = [inst.index.max() for inst in [standard_inst, forecast_inst]
                  if len(inst.index) > 0]
        stop = max(stimes) + pds.DateOffset(days=1) if len(stimes) > 0 else None

    if start is None or stop is None:
        raise ValueError("must either load in Instrument objects or provide" +
                         " starting and ending times")

    if start >= stop:
        raise ValueError("date range is zero or negative")

    # Initialize the output instrument
    f107_inst = pysat.Instrument()
    f107_inst.platform = standard_inst.platform
    f107_inst.name = standard_inst.name
    f107_inst.tag = tag
    f107_inst.date = start
    f107_inst.doy = int(start.strftime("%j"))
    fill_val = None

    f107_times = list()
    f107_values = list()

    # Cycle through the desired time range
    itime = start

    while itime < stop and inst_flag is not None:
        # Load and save the standard data for as many times as possible
        if inst_flag == 'standard':
github pysat / pysat / pysat / ssnl / avg.py View on Github external
Returns
    -------
    median : dictionary
        2D median accessed by data_label as a function of label1 and label2
        over the season delineated by bounds of passed instrument objects.
        Also includes 'count' and 'avg_abs_dev' as well as the values of
        the bin edges in 'bin_x' and 'bin_y'.

    """

    # const is either an Instrument or a Constellation, and we want to
    #  iterate over it.
    # If it's a Constellation, then we can do that as is, but if it's
    #  an Instrument, we just have to put that Instrument into something
    #  that will yeild that Instrument, like a list.
    if isinstance(const, pysat.Instrument):
        const = [const]
    elif not isinstance(const, pysat.Constellation):
        raise ValueError("Parameter must be an Instrument or a Constellation.")

    # create bins
    # seems to create the boundaries used for sorting into bins
    if auto_bin:
        binx = np.linspace(bin1[0], bin1[1], bin1[2]+1)
        biny = np.linspace(bin2[0], bin2[1], bin2[2]+1)
    else:
        binx = np.array(bin1)
        biny = np.array(bin2)

    # how many bins are used
    numx = len(binx)-1
    numy = len(biny)-1
github pysat / pysat / pysat / constellations / icon.py View on Github external
import pysat
"""
Creates a constellation from NASA ICON instrumentation
"""


ivm = pysat.Instrument('icon', 'ivm', sat_id='a', tag='level_2',
                       clean_level='clean', update_files=True)
euv = pysat.Instrument('icon', 'euv', sat_id='', tag='level_2',
                       clean_level='clean', update_files=True)
fuv = pysat.Instrument('icon', 'fuv', sat_id='', tag='level_2',
                       clean_level='clean', update_files=True)
mighti_green = pysat.Instrument('icon', 'mighti', sat_id='green',
                                tag='level_2', clean_level='clean',
                                update_files=True)
mighti_red = pysat.Instrument('icon', 'mighti', sat_id='red', tag='level_2',
                              clean_level='clean', update_files=True)

instruments = [ivm, euv, fuv, mighti_green, mighti_red]