How to use the pytesmo.io.ismn.interface.ISMN_Interface function in pytesmo

To help you get started, we’ve selected a few pytesmo 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 TUW-GEO / pytesmo / tests / test_ismn / test_interface.py View on Github external
def test_interface_network_init():
    """
    test limitation of interface to certain networks
    """

    path_header_values = os.path.join(os.path.dirname(__file__),
                                      '..', 'test-data', 'ismn', 'multinetwork', 'header_values')
    hv_interface = interface.ISMN_Interface(
        path_header_values, network=['SCAN'])
    assert hv_interface.list_networks().size == 1
    assert hv_interface.list_networks()[0] == 'SCAN'
    hv_interface = interface.ISMN_Interface(
        path_header_values, network=['SCAN', 'MAQU'])
    assert hv_interface.list_networks().size == 2
github TUW-GEO / pytesmo / tests / test_ismn / test_interface.py View on Github external
def test_interface_plotting():
    """
    test plotting of networks
    """
    path_header_values = os.path.join(os.path.dirname(__file__),
                                      '..', 'test-data', 'ismn', 'multinetwork', 'header_values')
    hv_interface = interface.ISMN_Interface(
        path_header_values, network=['SCAN'])
    fig, axes = hv_interface.plot_station_locations()
    return fig
github TUW-GEO / pytesmo / tests / test_ismn / test_interface.py View on Github external
test of the getting minimum and maxiumum observation time
    of a station
    """

    path_header_values = os.path.join(os.path.dirname(__file__),
                                      '..', 'test-data', 'ismn', 'format_header_values', 'SMOSMANIA')
    hv_interface = interface.ISMN_Interface(path_header_values)

    station = hv_interface.get_station('Narbonne')
    startd, endd = station.get_min_max_obs_timestamp()
    assert startd == datetime.datetime(2007, 1, 1, 1)
    assert endd == datetime.datetime(2007, 1, 31, 23)

    path_ceop_sep = os.path.join(os.path.dirname(__file__),
                                 '..', 'test-data', 'ismn', 'format_ceop_sep', 'SMOSMANIA')
    ceop_sep_interface = interface.ISMN_Interface(path_ceop_sep)

    station = ceop_sep_interface.get_station('Narbonne')
    startd, endd = station.get_min_max_obs_timestamp()
    assert startd == datetime.datetime(2007, 1, 1, 1)
    assert endd == datetime.datetime(2007, 1, 31, 23)
github TUW-GEO / pytesmo / tests / test_ismn / test_interface.py View on Github external
def test_min_max_obstime_networks():
    """
    test of the getting minimum and maxiumum observation time
    of several networks
    """

    path_header_values = os.path.join(os.path.dirname(__file__),
                                      '..', 'test-data', 'ismn', 'multinetwork', 'header_values')
    hv_interface = interface.ISMN_Interface(path_header_values)
    data = hv_interface.get_min_max_obs_timestamps(min_depth=0, max_depth=0.1)
    assert data.loc['MAQU']['end date'][
        0] == datetime.datetime(2010, 7, 31, 23)
    assert data.loc['MAQU']['end date'][
        1] == datetime.datetime(2010, 7, 31, 23)
    assert data.loc['MAQU']['start date'][
        1] == datetime.datetime(2008, 7, 1, 0)
    assert data.loc['SCAN']['start date'][
        1] == datetime.datetime(2007, 1, 1, 0)
    assert data.loc['SOILSCAPE']['start date'][
        1] == datetime.datetime(2012, 12, 14, 19)
github TUW-GEO / pytesmo / tests / test_ismn / test_interface.py View on Github external
def test_min_max_obstime_getting():
    """
    test of the getting minimum and maxiumum observation time
    of a station
    """

    path_header_values = os.path.join(os.path.dirname(__file__),
                                      '..', 'test-data', 'ismn', 'format_header_values', 'SMOSMANIA')
    hv_interface = interface.ISMN_Interface(path_header_values)

    station = hv_interface.get_station('Narbonne')
    startd, endd = station.get_min_max_obs_timestamp()
    assert startd == datetime.datetime(2007, 1, 1, 1)
    assert endd == datetime.datetime(2007, 1, 31, 23)

    path_ceop_sep = os.path.join(os.path.dirname(__file__),
                                 '..', 'test-data', 'ismn', 'format_ceop_sep', 'SMOSMANIA')
    ceop_sep_interface = interface.ISMN_Interface(path_ceop_sep)

    station = ceop_sep_interface.get_station('Narbonne')
    startd, endd = station.get_min_max_obs_timestamp()
    assert startd == datetime.datetime(2007, 1, 1, 1)
    assert endd == datetime.datetime(2007, 1, 31, 23)
github TUW-GEO / pytesmo / tests / test_ismn / test_interface.py View on Github external
def test_find_nearest_station():
    """
    Test nearest neighbor search
    """
    path_header_values = os.path.join(os.path.dirname(__file__),
                                      '..', 'test-data', 'ismn', 'multinetwork', 'header_values')
    hv_interface = interface.ISMN_Interface(
        path_header_values, network=['SCAN'])
    station, distance = hv_interface.find_nearest_station(-90, 35, True)
    assert station.station == "AAMU-jtg"
    assert station.network == "SCAN"
    nptest.assert_almost_equal(distance, 316228.53147802927)
github TUW-GEO / pytesmo / examples / compare_ISMN_ASCAT.py View on Github external
ascat_folder = os.path.join('R:\\', 'Datapool_processed', 'WARP', 'WARP5.5',
                                         'ASCAT_WARP5.5_R1.2', '080_ssm', 'netcdf')
ascat_grid_folder = os.path.join('R:\\', 'Datapool_processed', 'WARP', 'ancillary', 'warp5_grid')
# init the ASCAT_SSM reader with the paths

# let's not include the orbit direction since it is saved as 'A'
# or 'D' it can not be plotted
ascat_SSM_reader = ascat.AscatH25_SSM(ascat_folder, ascat_grid_folder,
                                      include_in_df=['sm', 'sm_noise', 'ssf', 'proc_flag'])


# set path to ISMN data
path_to_ismn_data = os.path.join('D:\\', 'small_projects', 'cpa_2013_07_ISMN_userformat_reader', 'header_values_parser_test')
# Initialize reader
ISMN_reader = ismn.ISMN_Interface(path_to_ismn_data)

i = 0

label_ascat = 'sm'
label_insitu = 'insitu_sm'

# this loops through all stations that measure soil moisture
for station in ISMN_reader.stations_that_measure('soil moisture'):
    
    # this loops through all time series of this station that measure soil moisture
    # between 0 and 0.1 meters
    for ISMN_time_series in station.data_for_variable('soil moisture', min_depth=0, max_depth=0.1):
        
        ascat_time_series = ascat_SSM_reader.read_ssm(ISMN_time_series.longitude,
                                                      ISMN_time_series.latitude,
                                                      mask_ssf=True,
github TUW-GEO / pytesmo / examples / plot_ISMN_data.py View on Github external
import pytesmo.io.ismn.interface as ismn
import matplotlib.pyplot as plt
import random

# path unzipped file downloaded from the ISMN web portal
# on windows the first string has to be your drive letter
# like 'C:\\'
#path_to_ismn_data = os.path.join('path', 'to', 'ISMN_data',
                                 #'from', 'ISMN website')

path_to_ismn_data = '/pytesmo/testdata/ismn/format_ceop_sep/SMOSMANIA'

# initialize interface, this can take up to a few minutes the first
# time, since all metadata has to be collected
ISMN_reader = ismn.ISMN_Interface(path_to_ismn_data)

# plot available station on a map
fig, axes = ISMN_reader.plot_station_locations()
plt.show()

# select random network and station to plot
networks = ISMN_reader.list_networks()
print "Available Networks:"
print networks

network = random.choice(networks)
stations = ISMN_reader.list_stations(network=network)
print "Available Stations in Network %s" % network
print stations

station = random.choice(stations)