Exemplo n.º 1
0
    def __init__(self,
                 on=True,
                 make_default_refs=True,
                 active_range=(InfDateTime('-inf'), InfDateTime('inf')),
                 **kwargs):  # default min + max values for timespan
        """
        Initialize default Mover/Weatherer parameters

        All parameters are optional (kwargs)

        :param on: boolean as to whether the object is on or not. Default is on
        :param active_range: Range of datetimes for when the mover should be
                             active
        :type active_range: 2-tuple of datetimes
        """
        super(Process, self).__init__(**kwargs)

        self.on = on
        self._active = self.on

        self._check_active_startstop(*active_range)

        self._active_range = active_range

        # empty dict since no array_types required for all movers at present
        self.make_default_refs = make_default_refs
Exemplo n.º 2
0
    def __init__(self, **kwargs):
        """
        Initialize default Mover/Weatherer parameters

        All parameters are optional (kwargs)

        :param on: boolean as to whether the object is on or not. Default is on
        :param active_range: Range of datetimes for when the mover should be
                             active
        :type active_range: 2-tuple of datetimes
        """
        self.name = kwargs.pop('name', self.__class__.__name__)

        self.on = kwargs.pop('on', True)
        self._active = self.on

        active_range = kwargs.pop('active_range',
                                  (InfDateTime('-inf'), InfDateTime('inf')))

        self._check_active_startstop(*active_range)

        self._active_range = active_range

        # empty dict since no array_types required for all movers at present
        self.array_types = set()
        self.make_default_refs = kwargs.pop('make_default_refs', True)
Exemplo n.º 3
0
def test_default_properties():
    mover = Mover()

    assert mover.on is True

    assert mover.active_range == (InfDateTime('-inf'), InfDateTime('inf'))

    assert mover.make_default_refs is True
Exemplo n.º 4
0
    def test_init(self):
        weatherer = Weatherer()

        print weatherer
        assert weatherer.on
        assert weatherer.active
        assert weatherer.active_range == (InfDateTime('-inf'),
                                          InfDateTime('inf'))
Exemplo n.º 5
0
def test_constant_wind_bounds():
    """
    tests that a constan_wind returns the limit bounds
    """
    wind = constant_wind(10, 45, 'knots')

    assert wind.data_start == InfDateTime("-inf")

    assert wind.data_stop == InfDateTime("inf")
Exemplo n.º 6
0
    def test_init(self):
        weatherer = Weatherer()

        print weatherer
        assert weatherer.on
        assert weatherer.active
        assert weatherer.active_start == InfDateTime('-inf')
        assert weatherer.active_stop == InfDateTime('inf')
        assert weatherer.array_types == {'mass_components', 'mass'}
Exemplo n.º 7
0
    def test_init(self):
        weatherer = Weatherer()

        print weatherer
        assert weatherer.on
        assert weatherer.active
        assert weatherer.active_range == (InfDateTime('-inf'),
                                          InfDateTime('inf'))
        assert weatherer.array_types == {
            'mass_components', 'mass', 'init_mass'
        }
Exemplo n.º 8
0
def test_default_properties():
    mover = Mover()

    assert mover.name == 'Mover'
    assert mover.on is True

    assert mover.active_range == (InfDateTime('-inf'),
                                  InfDateTime('inf'))

    assert mover.array_types == set()
    assert mover.make_default_refs is True
Exemplo n.º 9
0
def test_default_properties():
    mover = PyMover()

    #assert mover.name == 'PyMover'
    assert mover.on is True

    assert mover.active_range == (InfDateTime('-inf'), InfDateTime('inf'))

    #assert mover.array_types == set()
    assert mover.make_default_refs is True

    assert mover.default_num_method == 'RK2'
Exemplo n.º 10
0
    def __init__(self,
                 fraction_sprayed,
                 active_range=(InfDateTime('-inf'), InfDateTime('inf')),
                 waves=None,
                 efficiency=1.0,
                 **kwargs):
        '''
        another mass removal mechanism. The volume specified gets dispersed
        with efficiency based on wave conditions.

        :param volume: volume of oil (not oil/water?) applied with surfactant
        :type volume: float
        :param units: volume units
        :type units: str
        :param active_range: Range of datetimes for when the mover should be
                             active
        :type active_range: 2-tuple of datetimes
        :param waves: waves object - query to get height. It must contain
            get_value() method. Default is None to support object creation by
            WebClient before a waves object is defined
        :type waves: an object with same interface as gnome.environment.Waves

        Optional Argument: Either efficiency or waves must be set before
        running the model. If efficiency is not set, then use wave height to
        estimate an efficiency

        :param efficiency: efficiency of operation.
        :type efficiency: float between 0 and 1

        remaining kwargs include 'on' and 'name' and these are passed to base
        class via super
        '''
        super(ChemicalDispersion, self).__init__(active_range=active_range,
                                                 efficiency=efficiency,
                                                 **kwargs)

        # fraction_sprayed must be > 0 and <= 1.0
        self.fraction_sprayed = fraction_sprayed
        self.waves = waves

        # rate is set the first timestep in which the object becomes active
        self._rate = None

        # fixme: this note was here: since efficiency can also be set - do not
        #        make_default_refs but we need waves!
        # we need a way to override efficiency, rather than disabling
        # default-refs but the current code sets the efficiency attribute
        # from waves.. maybe a static_efficiency property -- if it is not None,
        # then it is used, rather than any computation being made.
        self.make_default_refs = False if efficiency else True
Exemplo n.º 11
0
 def data_start(self):
     '''
         The Water object doesn't directly manage a time series of data,
         so it will not have a data range.
         We will just return an infinite range for Water.
     '''
     return InfDateTime("-inf")
Exemplo n.º 12
0
    def test_update_active_start(self):
        '''
        active stop should be updated if we update active start or thickness
        '''
        burn = Burn(self.area,
                    self.thick,
                    active_range=(active_start, InfDateTime('inf')),
                    name='test_burn',
                    on=False)   # this is ignored!

        # use burn constant for test - it isn't stored anywhere
        duration = ((uc.convert('Length', burn.thickness_units, 'm',
                                burn.thickness) -
                     burn._min_thickness) /
                    burn._burn_constant)

        assert (burn.active_range[1] ==
                burn.active_range[0] + timedelta(seconds=duration))

        # after changing active start, active stop should still match the
        # duration.
        burn.active_range = (burn.active_range[0] + timedelta(days=1),
                             burn.active_range[1])
        assert (burn.active_range[1] ==
                burn.active_range[0] + timedelta(seconds=duration))
Exemplo n.º 13
0
    def test_active_start_after_one_timestep(self):
        start_time = self.model_time + timedelta(seconds=self.time_step)

        mv = Mover(active_range=(start_time, InfDateTime('inf')))
        mv.prepare_for_model_step(self.sc, self.time_step, self.model_time)

        assert mv.active is False
Exemplo n.º 14
0
def test_dispersion_not_active(oil, temp, num_elems):
    '''
    Fuel Oil #6 does not exist...
    '''
    disp = NaturalDispersion(waves, water)
    (sc, time_step) = \
        weathering_data_arrays(disp.array_types,
                               water)[:2]

    sc.amount = 10000
    model_time = (sc.spills[0].release_time +
                  timedelta(seconds=time_step))

    disp.prepare_for_model_run(sc)

    assert np.all(sc.mass_balance['natural_dispersion'] == 0)
    assert np.all(sc.mass_balance['sedimentation'] == 0)

    new_model_time = (sc.spills[0].release_time +
                      timedelta(seconds=3600))

    disp.active_range = (new_model_time, InfDateTime('inf'))
    disp.prepare_for_model_step(sc, time_step, model_time)

    assert np.all(sc.mass_balance['natural_dispersion'] == 0)
    assert np.all(sc.mass_balance['sedimentation'] == 0)

    disp.weather_elements(sc, time_step, model_time)

    assert np.all(sc.mass_balance['natural_dispersion'] == 0)
    assert np.all(sc.mass_balance['sedimentation'] == 0)
Exemplo n.º 15
0
    def test_active_start_after_half_timestep(self):
        self.mv.active_range = ((self.model_time +
                                 timedelta(seconds=self.time_step / 2)),
                                InfDateTime('inf'))

        self.mv.prepare_for_model_step(self.sc, self.time_step,
                                       self.model_time)

        assert self.mv.active is True
Exemplo n.º 16
0
def check_water_defaults(water_obj):
    assert water_obj.name == 'Water'

    assert water_obj.data_start == InfDateTime("-inf")
    assert water_obj.data_stop == InfDateTime("inf")

    assert water_obj.temperature == 300.0
    assert water_obj.salinity == 35.0
    assert water_obj.sediment == .005
    assert water_obj.wave_height is None
    assert water_obj.fetch is None

    assert water_obj.units['temperature'] == 'K'
    assert water_obj.units['salinity'] == 'psu'
    assert water_obj.units['sediment'] == 'kg/m^3'
    assert water_obj.units['wave_height'] == 'm'
    assert water_obj.units['fetch'] == 'm'
    assert water_obj.units['density'] == 'kg/m^3'
    assert water_obj.units['kinematic_viscosity'] == 'm^2/s'
Exemplo n.º 17
0
def test_timespan():
    """
    Ensure the active flag is being set correctly and checked,
    such that if active=False, the delta produced by get_move = 0
    """
    time_step = 15 * 60  # seconds

    start_pos = (3., 6., 0.)
    rel_time = datetime(2012, 8, 20, 13)  # yyyy/month/day/hr/min/sec

    sc = sample_sc_release(5, start_pos, rel_time)

    # value is given as (r,theta)
    model_time = rel_time
    time_val = np.zeros((1, ), dtype=datetime_value_2d)
    time_val['time'] = rel_time
    time_val['value'] = (2., 25.)

    wm = WindMover(Wind(timeseries=time_val,
                        units='meter per second'),
                   active_range=(model_time + timedelta(seconds=time_step),
                                 InfDateTime('inf')))

    wm.prepare_for_model_run()
    wm.prepare_for_model_step(sc, time_step, model_time)

    delta = wm.get_move(sc, time_step, model_time)
    wm.model_step_is_done()

    assert wm.active is False
    assert np.all(delta == 0)  # model_time + time_step = active_start

    wm.active_range = (model_time - timedelta(seconds=time_step / 2),
                       InfDateTime('inf'))
    wm.prepare_for_model_step(sc, time_step, model_time)

    delta = wm.get_move(sc, time_step, model_time)
    wm.model_step_is_done()

    assert wm.active is True
    print '''\ntest_timespan delta \n{0}'''.format(delta)
    assert np.all(delta[:, :2] != 0)  # model_time + time_step > active_start
Exemplo n.º 18
0
    def data_stop(self):
        """
        The stop time of the valid data for this wind timeseries

        If there is one data point -- it's a constant wind
        so data_start is -InfDateTime
        """
        if self.ossm.get_num_values() == 1:
            return InfDateTime("inf")
        else:
            return sec_to_datetime(self.ossm.get_end_time())
Exemplo n.º 19
0
    def test_units_exception(self, area_units, thickness_units):
        ''' tests incorrect units raises exception '''
        with raises(uc.InvalidUnitError):
            self.burn.area_units = "in"

        with raises(uc.InvalidUnitError):
            self.burn.thickness_units = "m^2"

        with raises(uc.InvalidUnitError):
            Burn(10, 1, (datetime.now(), InfDateTime('inf')),
                 area_units=area_units,
                 thickness_units=thickness_units)
Exemplo n.º 20
0
    def timeseries(self, value):
        '''
        1. convert value to numpy array with dtype=datetime_value_1d
        2. set timeseries and also sets active_stop = timeseries['time'][-1]
        '''
        value = np.asarray(value, dtype=datetime_value_1d)

        # prepends active_start to _timeseries array. This is for convenience
        to_insert = np.zeros(1, dtype=datetime_value_1d)

        if self.active_start != InfDateTime('-inf'):
            to_insert['time'][0] = np.datetime64(self.active_start)

        self._timeseries = np.insert(value, 0, to_insert)
        self.active_stop = self._timeseries['time'][-1].astype(datetime)
Exemplo n.º 21
0
    def _weather_elements_helper(self, burn, avg_frac_water=0.0):
        '''
        refactored model run from test_weather_elements to this helper function
        It is also used by next test:
        test_elements_weather_slower_with_frac_water
        '''
        self.prepare_test_objs()

        model_time = rel_time
        burn.prepare_for_model_run(self.sc)

        # once burn becomes active, sc.mass_balance['burned'] > 0.0 and
        # burn becomes inactive once
        # burn._oil_thickness == burn._min_thickness
        step_num = 0
        while ((model_time > burn.active_range[0] and burn.active)
               or self.sc.mass_balance['burned'] == 0.0):

            num_rel = self.release_elements(time_step, model_time)
            if num_rel > 0:
                self.sc['frac_water'][:] = avg_frac_water

            self.step(burn, time_step, model_time)
            dt = timedelta(seconds=time_step)
            if (model_time + dt <= burn.active_range[0]
                    or model_time >= burn.active_range[1]):
                # if model_time + dt == burn.active start, then start the burn
                # in next step
                assert not burn.active
            else:
                assert burn.active

            model_time += dt
            step_num += 1

            if step_num > 100:
                # none of the tests take that long, so break it
                msg = "Test took more than 100 iterations for Burn, check test"
                raise Exception(msg)
                break

        # check that active stop is being correctly set
        assert InfDateTime('inf') > burn.active_range[1]
        print '\nCompleted steps: {0:2}'.format(step_num)
Exemplo n.º 22
0
    def test_init(self):
        '''
        active stop is ignored if set by user
        '''
        burn = Burn(self.area,
                    self.thick,
                    active_range=(active_start, InfDateTime('inf')),
                    name='test_burn',
                    on=False)  # this is ignored!

        # use burn constant for test - it isn't stored anywhere
        duration = (
            uc.convert('Length', burn.thickness_units, 'm', burn.thickness) -
            burn._min_thickness) / burn._burn_constant

        assert (burn.active_range[1] == burn.active_range[0] +
                timedelta(seconds=duration))
        assert burn.name == 'test_burn'
        assert not burn.on
Exemplo n.º 23
0
    def test_active_start_modeltime(self):
        mv = Mover(active_range=(self.model_time, InfDateTime('inf')))
        mv.prepare_for_model_step(self.sc, self.time_step, self.model_time)

        assert mv.active is True
Exemplo n.º 24
0
def test_constant_wind_mover_bounds():
    wm = constant_wind_mover(10, 45, units='knots')

    assert wm.data_start == InfDateTime("-inf")
    assert wm.data_stop == InfDateTime("inf")
Exemplo n.º 25
0
 def data_start(self):
     return InfDateTime("-inf")
Exemplo n.º 26
0
 def data_stop(self):
     return InfDateTime("inf")
Exemplo n.º 27
0
def make_model(images_dir=os.path.join(base_dir, 'images')):
    print 'initializing the model'

    start_time = datetime(2015, 5, 14, 0, 0)

    # 1 day of data in file
    # 1/2 hr in seconds
    model = Model(start_time=start_time,
                  duration=timedelta(days=1.75),
                  time_step=60 * 60,
                  uncertain=True)

#     mapfile = get_datafile(os.path.join(base_dir, './ak_arctic.bna'))
#
#     print 'adding the map'
#     model.map = MapFromBNA(mapfile, refloat_halflife=1)  # seconds
#
#     # draw_ontop can be 'uncertain' or 'forecast'
#     # 'forecast' LEs are in black, and 'uncertain' are in red
#     # default is 'forecast' LEs draw on top
#     renderer = Renderer(mapfile, images_dir, image_size=(800, 600),
#                         output_timestep=timedelta(hours=2),
#                         draw_ontop='forecast')
#
#     print 'adding outputters'
#     model.outputters += renderer

    model.outputters += WeatheringOutput('.\\')

    netcdf_file = os.path.join(base_dir, 'script_weatherers.nc')
    scripting.remove_netcdf(netcdf_file)
    model.outputters += NetCDFOutput(netcdf_file, which_data='all',
                                     output_timestep=timedelta(hours=1))

    print 'adding a spill'
    # for now subsurface spill stays on initial layer
    # - will need diffusion and rise velocity
    # - wind doesn't act
    # - start_position = (-76.126872, 37.680952, 5.0),
    end_time = start_time + timedelta(hours=24)
    spill = point_line_release_spill(num_elements=100,
                                     start_position=(-164.791878561,
                                                     69.6252597267, 0.0),
                                     release_time=start_time,
                                     end_release_time=end_time,
                                     amount=1000,
                                     substance='ALASKA NORTH SLOPE (MIDDLE PIPELINE, 1997)',
                                     units='bbl')

    # set bullwinkle to .303 to cause mass goes to zero bug at 24 hours (when continuous release ends)
    spill.substance._bullwinkle = .303
    model.spills += spill

    print 'adding a RandomMover:'
    # model.movers += RandomMover(diffusion_coef=50000)

    print 'adding a wind mover:'

    series = np.zeros((2,), dtype=datetime_value_2d)
    series[0] = (start_time, (20, 0))
    series[1] = (start_time + timedelta(hours=23), (20, 0))

    wind2 = Wind(timeseries=series, units='knot')

    w_mover = WindMover(wind)
    model.movers += w_mover

    print 'adding weatherers and cleanup options:'

    # define skimmer/burn cleanup options
    skim1_start = start_time + timedelta(hours=15.58333)
    skim2_start = start_time + timedelta(hours=16)

    skim1_active_range = (skim1_start, skim1_start + timedelta(hours=8.))
    skim2_active_range = (skim2_start, skim2_start + timedelta(hours=12.))

    units = spill.units

    skimmer1 = Skimmer(80, units=units, efficiency=0.36,
                      active_range=skim1_active_range)
    skimmer2 = Skimmer(120, units=units, efficiency=0.2,
                      active_range=skim2_active_range)

    burn_start = start_time + timedelta(hours=36)
    burn = Burn(1000., .1,
                active_range=(burn_start, InfDateTime('inf')), efficiency=.2)

    chem_start = start_time + timedelta(hours=24)
    chem_active_range = (chem_start, chem_start + timedelta(hours=8))
#     c_disp = ChemicalDispersion(0.5, efficiency=0.4,
#                                 active_start=chem_start,
#                                 active_stop=chem_start + timedelta(hours=8))


    model.environment += [Water(280.928), wind, waves]

    model.weatherers += Evaporation(water, wind)
    model.weatherers += Emulsification(waves)
    model.weatherers += NaturalDispersion(waves, water)
    model.weatherers += skimmer1
    model.weatherers += skimmer2
    model.weatherers += burn
#     model.weatherers += c_disp

    return model
Exemplo n.º 28
0
    RandomVerticalMover(),
    SimpleMover(velocity=(10.0, 10.0, 0.0)),
    map.MapFromBNA(testdata['MapFromBNA']['testmap'], 6),
    NetCDFOutput(os.path.join(base_dir, u'xtemp.nc')),
    Renderer(testdata['Renderer']['bna_sample'],
             os.path.join(base_dir, 'output_dir')),
    WeatheringOutput(),
    spill.PointLineRelease(release_time=datetime.now(),
                           num_elements=10,
                           start_position=(0, 0, 0)),
    spill.point_line_release_spill(10, (0, 0, 0), datetime.now()),
    spill.elements.ElementType(substance=test_oil),
    Skimmer(100, 'kg', 0.3,
            (datetime(2014, 1, 1, 0, 0), datetime(2014, 1, 1, 4, 0))),
    Burn(100,
         1, (datetime(2014, 1, 1, 0, 0), InfDateTime('inf')),
         efficiency=.9),
    ChemicalDispersion(
        .2, (datetime(2014, 1, 1, 0, 0), datetime(2014, 1, 1, 4, 0)),
        efficiency=.3),
    # todo: ask Caitlin how to fix
    # movers.RiseVelocityMover(),
    # todo: This is incomplete - no _schema for
    #       SpatialRelease, GeoJson
    # spill.SpatialRelease(datetime.now(), ((0, 0, 0), (1, 2, 0))),
    TrajectoryGeoJsonOutput(),
)


@pytest.mark.parametrize("obj", g_objects)
def test_serial_deserial(saveloc_, obj):
Exemplo n.º 29
0
    def __init__(self,
                 area=None,
                 thickness=None,
                 active_range=(InfDateTime('-inf'), InfDateTime('inf')),
                 area_units='m^2',
                 thickness_units='m',
                 efficiency=1.0,
                 wind=None,
                 water=None,
                 **kwargs):
        '''
        Set the area of boomed oil to be burned.
        Cleanup operations must have a valid datetime for active start,
        cannot use -inf. Cannot set active stop - burn automatically stops
        when oil/water thickness reaches 2mm.

        :param float area: area of boomed oil/water mixture to burn
        :param float thickness: thickness of boomed oil/water mixture
        :param datetime active_range: time when the burn starts is the only
                                      thing we track.  However we give a range
                                      to be consistent with all other
                                      weatherers.
        :param str area_units: default is 'm^2'
        :param str thickness_units: default is 'm'
        :param float efficiency: burn efficiency, must be greater than 0 and
            less than or equal to 1.0
        :param wind: gnome.environment.Wind object. Only used to set
            efficiency if efficiency is None. Efficiency is defined as:
            1 - 0.07 * wind.get_value(model_time)
            where wind.get_value(model_time) is value of wind at model_time

        Kwargs passed onto base class:

        :param str name: name of object
        :param bool on: whether object is on or not for the run

        '''
        super(Burn, self).__init__(active_range=active_range,
                                   efficiency=efficiency,
                                   **kwargs)

        # initialize user units to valid units - setters following this will
        # initialize area_units and thickness_units per input values
        self._area_units = 'm^2'
        self._thickness_units = 'm'

        # thickness of burned/boomed oil which is updated at each timestep
        # this will be set once we figure out how much oil will be burned
        # in prepare_for_model_step()
        self._oilwater_thickness = None  # in SI units
        self._min_thickness = 0.002  # stop burn threshold in SI 2mm

        # following are set once LEs are marked for burn
        self._burn_constant = 0.000058
        self._oilwater_thick_burnrate = None
        self._oil_vol_burnrate = None  # burn rate of only the oil

        # validate user units before setting _area_units/_thickness_units
        self._thickness = thickness
        self.area = area

        # setters will validate the units
        self.area_units = area_units
        self.thickness_units = thickness_units
        self.wind = wind
        self.water = water

        # initialize rates and active stop based on frac_water = 0.0
        self._init_rate_duration()
Exemplo n.º 30
0
def make_model(uncertain=False, mode='gnome'):
    '''
    Create a model from the data in sample_data/boston_data
    It contains:
      - the GeoProjection
      - wind mover
      - random mover
      - cats shio mover
      - cats ossm mover
      - plain cats mover
    '''
    start_time = datetime(2013, 2, 13, 9, 0)
    model = Model(start_time=start_time,
                  duration=timedelta(days=2),
                  time_step=timedelta(minutes=30).total_seconds(),
                  uncertain=uncertain,
                  map=MapFromBNA(testdata['boston_data']['map'],
                                 refloat_halflife=1),
                  mode=mode)

    print 'adding a spill'
    start_position = (144.664166, 13.441944, 0.0)
    end_release_time = start_time + timedelta(hours=6)
    spill_amount = 1000.0
    spill_units = 'kg'
    model.spills += point_line_release_spill(num_elements=1000,
                                             start_position=start_position,
                                             release_time=start_time,
                                             end_release_time=end_release_time,
                                             amount=spill_amount,
                                             units=spill_units,
                                             substance=test_oil)
    spill = model.spills[-1]
    spill_volume = spill.get_mass() / spill.substance.density_at_temp()
    # need a scenario for SimpleMover
    # model.movers += SimpleMover(velocity=(1.0, -1.0, 0.0))

    print 'adding a RandomMover:'
    model.movers += RandomMover(diffusion_coef=100000)

    print 'adding a wind mover:'

    series = np.zeros((2, ), dtype=datetime_value_2d)
    series[0] = (start_time, (5, 180))
    series[1] = (start_time + timedelta(hours=18), (5, 180))

    w_mover = WindMover(Wind(timeseries=series, units='m/s'))

    model.movers += w_mover
    model.environment += w_mover.wind

    print 'adding a cats shio mover:'

    c_mover = CatsMover(testdata['boston_data']['cats_curr2'],
                        tide=Tide(testdata['boston_data']['cats_shio']))

    # c_mover.scale_refpoint should automatically get set from tide object
    c_mover.scale = True  # default value
    c_mover.scale_value = -1

    # tide object automatically gets added by model
    model.movers += c_mover

    print 'adding a cats ossm mover:'

    c_mover = CatsMover(testdata['boston_data']['cats_curr2'],
                        tide=Tide(testdata['boston_data']['cats_ossm']))

    c_mover.scale = True  # but do need to scale (based on river stage)
    c_mover.scale_refpoint = (-70.65, 42.58333, 0.0)
    c_mover.scale_value = 1.

    print 'adding a cats mover:'

    c_mover = CatsMover(testdata['boston_data']['cats_curr3'])
    c_mover.scale = True  # but do need to scale (based on river stage)
    c_mover.scale_refpoint = (-70.78333, 42.39333, 0.0)

    # the scale factor is 0 if user inputs no sewage outfall effects
    c_mover.scale_value = .04
    model.movers += c_mover

    # TODO: seg faulting for component mover - comment test for now
    # print "adding a component mover:"
    # comp_mover = ComponentMover(testdata['boston_data']['component_curr1'],
    #                             testdata['boston_data']['component_curr2'],
    #                             w_mover.wind)
    # TODO: callback did not work correctly below - fix!
    # comp_mover = ComponentMover(component_file1,
    #                             component_file2,
    #                             Wind(timeseries=series, units='m/s'))

    # comp_mover.ref_point = (-70.855, 42.275)
    # comp_mover.pat1_angle = 315
    # comp_mover.pat1_speed = 19.44
    # comp_mover.pat1_speed_units = 1
    # comp_mover.pat1ScaleToValue = .138855
    # comp_mover.pat2_angle = 225
    # comp_mover.pat2_speed = 19.44
    # comp_mover.pat2_speed_units = 1
    # comp_mover.pat2ScaleToValue = .05121

    # model.movers += comp_mover

    print 'adding a Weatherer'
    model.environment += Water(311.15)
    skim_start = start_time + timedelta(hours=3)
    model.weatherers += [
        Evaporation(),
        Skimmer(spill_amount * .5,
                spill_units,
                efficiency=.3,
                active_range=(skim_start, skim_start + timedelta(hours=2))),
        Burn(0.2 * spill_volume,
             1.0, (skim_start, InfDateTime('inf')),
             efficiency=0.9)
    ]

    model.outputters += \
        CurrentJsonOutput(model.find_by_attr('_ref_as', 'current_movers',
                                             model.movers, allitems=True))

    return model
Exemplo n.º 31
0
def test_iso_format():
    dt = InfDateTime(2012, 10, 20)

    assert dt.isoformat() == "2012-10-20T00:00:00"