def make_model():

    start_time = datetime(2015, 5, 14, 0)
    model = Model(
        time_step=3600 * 24,  # one day
        start_time=start_time,
        duration=timedelta(days=3),
    )
    model.cache_enabled = False
    model.uncertain = False

    # N = 10  # a line of ten points
    # line_pos = np.zeros((N, 3), dtype=np.float64)
    # line_pos[:, 0] = np.linspace(rel_start_pos[0], rel_end_pos[0], N)
    # line_pos[:, 1] = np.linspace(rel_start_pos[1], rel_end_pos[1], N)

    # start_pos = (-164.01696, 72.921024, 0)
    # model.spills += point_line_release_spill(1,
    #                                          start_position=start_pos,
    #                                          release_time=model.start_time,
    #                                          end_position=start_pos)

    # release = SpatialRelease(start_position=line_pos,
    #                          release_time=model.start_time)
    # model.spills += Spill(release)

    c_ice_mover = IceMover(curr_file, topology_file)
    model.movers += c_ice_mover

    model.outputters += IceImageOutput(c_ice_mover,
                                       viewport=((-175.0, 65.0), (-145.0,
                                                                  75.05)))

    return model
def test_ice_image_mid_run():
    """
        Test image outputter with a model
        NOTE: could it be tested with just a mover, and not a full model?
          -- that gets tricky with the cache and timesteps...
    """
    start_time = datetime(2015, 5, 14, 0)
    model = Model(time_step=3600 * 24, start_time=start_time, duration=timedelta(days=3))  # one day
    model.cache_enabled = False
    model.uncertain = False

    c_ice_mover = IceMover(curr_file, topology_file)
    model.movers += c_ice_mover

    # run the model a couple steps
    step = model.step()
    step = model.step()

    # now add the outputter
    model.outputters += IceImageOutput(c_ice_mover, viewport=((-175.0, 65.0), (-145.0, 75.05)))

    # and run some more:
    step = model.step()
    step = model.step()

    # and check the output
    ice_output = step["IceImageOutput"]

    for key in ("time_stamp", "thickness_image", "concentration_image", "bounding_box", "projection"):
        assert key in ice_output

        print "thickness img size:", len(ice_output["thickness_image"])
        print "concentration img size:", len(ice_output["concentration_image"])
def make_model():

    start_time = datetime(2015, 5, 14, 0)
    model = Model(time_step=3600*24,  # one day
                  start_time=start_time,
                  duration=timedelta(days=3),)
    model.cache_enabled = False
    model.uncertain = False

    # N = 10  # a line of ten points
    # line_pos = np.zeros((N, 3), dtype=np.float64)
    # line_pos[:, 0] = np.linspace(rel_start_pos[0], rel_end_pos[0], N)
    # line_pos[:, 1] = np.linspace(rel_start_pos[1], rel_end_pos[1], N)

    # start_pos = (-164.01696, 72.921024, 0)
    # model.spills += point_line_release_spill(1,
    #                                          start_position=start_pos,
    #                                          release_time=model.start_time,
    #                                          end_position=start_pos)

    # release = SpatialRelease(start_position=line_pos,
    #                          release_time=model.start_time)
    # model.spills += Spill(release)

    c_ice_mover = IceMover(curr_file, topology_file)
    model.movers += c_ice_mover

    model.outputters += IceImageOutput(c_ice_mover,
                                       viewport=((-175.0, 65.0),
                                                 (-145.0, 75.05))
                                       )

    return model
def test_ice_image_mid_run():
    '''
        Test image outputter with a model
        NOTE: could it be tested with just a mover, and not a full model?
          -- that gets tricky with the cache and timesteps...
    '''
    start_time = datetime(2015, 5, 14, 0)
    model = Model(
        time_step=3600 * 24,  # one day
        start_time=start_time,
        duration=timedelta(days=3),
    )
    model.cache_enabled = False
    model.uncertain = False

    c_ice_mover = IceMover(curr_file, topology_file)
    model.movers += c_ice_mover

    # run the model a couple steps
    step = model.step()
    step = model.step()

    # now add the outputter
    model.outputters += IceImageOutput(c_ice_mover,
                                       viewport=((-175.0, 65.0), (-145.0,
                                                                  75.05)))

    # and run some more:
    step = model.step()
    step = model.step()

    # and check the output
    ice_output = step['IceImageOutput']

    for key in ('time_stamp', 'thickness_image', 'concentration_image',
                'bounding_box', 'projection'):
        assert key in ice_output

        print 'thickness img size:', len(ice_output['thickness_image'])
        print 'concentration img size:', len(ice_output['concentration_image'])
def test_ice_image_mid_run():
    '''
    Test image outputter with a model 
    NOTE: could it be tested with just a mover, and not a full model?
      -- that gets tricky with the cache and timesteps...
    '''
    start_time = datetime(2015, 5, 14, 0)
    model = Model(time_step=3600*24, # one day
                  start_time=start_time,
                  duration=timedelta(days=3),)
    model.cache_enabled = False
    model.uncertain = False
    c_ice_mover = IceMover(curr_file, topology_file)
    model.movers += c_ice_mover

    ## run the model a couple steps
    step = model.step()
    step = model.step()

    ## now add the outputter
    iio = IceImageOutput(c_ice_mover)
    model.outputters += iio

    ## and run some more:

    step = model.step()
    step = model.step()
    ## and check the output
    ice_output = step['IceImageOutput']
    # print ice_output['time_stamp']
    # print ice_output['concentration_image'][:50] # could be really big!
    # print ice_output['bounding_box']
    # print ice_output['projection']
    for key in ('time_stamp',
                'thickness_image',
                'concentration_image',
                'bounding_box',
                'projection'):
        assert key in ice_output