Ejemplo n.º 1
0
class UnitTests(unittest.TestCase):
    def setUp(self):
        from jarkus.transects import Transects
        self.tr = Transects()
    def test_initurl(self):
        from jarkus.transects import Transects
        url = 'http://opendap.deltares.nl/thredds/dodsC/opendap/rijkswaterstaat/jarkus/profiles/transect.nc'
        self.assertEqual(Transects(url=url).url, url)
    def test_set_filter_bool(self):
        shape = self.tr.ds.variables['id'].shape
        B = np.ones(shape) == 0 # all false
        idx = -1
        B[-1] = True
        self.tr.set_filter(alongshore=B)
        self.assertEqual(self.tr.get_data('id'), self.tr.ds.variables['id'][idx])
    def test_set_filter_id(self):
        id = 7e6
        self.tr.set_filter(id=id)
        self.assertEqual(self.tr.get_data('id'), id)
    def test_set_filter_idx(self):
        idx = -10
        self.tr.set_filter(alongshore=idx)
        self.assertEqual(self.tr.get_data('id'), self.tr.ds.variables['id'][idx])
    def test_set_filter_year(self):
        self.tr.set_filter(year=2006)
    def test_get_jrk(self):
        idx = 100
        self.tr.reset_filter()
        self.tr.set_filter(time=-1)
        ids = self.tr.get_data('id')
        idx = np.nonzero(ids==8006000)[0]
        self.tr.set_filter(alongshore=idx[0])
        self.tr.get_jrk()
Ejemplo n.º 2
0
# -*- coding: utf-8 -*-
"""
Created on Fri Dec  6 19:53:24 2013

@author: heijer
"""

from jarkus.transects import Transects
import numpy as np

Jk = Transects(url='http://dtvirt5.deltares.nl:8080/thredds/dodsC/opendap/rijkswaterstaat/jarkus/profiles/transect_r2013_filled.nc')
ids = Jk.get_data('id')
idxs = np.floor(ids/1e6) == 8
for idx in np.nonzero(idxs)[0]:
    Jk.set_filter(alongshore=idx)
    with open('transect_%i.jrk'%ids[idx], 'w') as f:
        f.write(Jk.get_jrk())