def obs_sesh(request, variable_sesh, history_stn1_hourly, history_stn2_hourly,
              var_temp_point, var_temp_point2,
              var_precip_net1_1, var_precip_net2_1):
     if request.param in [MonthlyAverageOfDailyMaxTemperature, MonthlyAverageOfDailyMinTemperature]:
         observations = [
             Obs(variable=var, history=hx,
                 time=datetime.datetime(2000, month, day, hour), datum=float(hour))
             for (var, hx) in [(var_temp_point, history_stn1_hourly),
                               (var_temp_point2, history_stn2_hourly)]
             for month in months
             for day in days
             for hour in hours
         ]
     else:
         observations = [
             Obs(variable=var, history=hx,
                 time=datetime.datetime(2000, month, day, hour), datum=1.0)
             for (var, hx) in [(var_precip_net1_1, history_stn1_hourly),
                               (var_precip_net2_1, history_stn2_hourly)]
             for month in months
             for day in days
             for hour in hours
         ]
     for sesh in generic_sesh(variable_sesh , observations):
         yield sesh
 def obs_sesh(variable_sesh, var_temp_point, history_stn1_daily):
     observations = [
         Obs(id=i + 100, variable=var_temp_point, history=history_stn1_daily,
               time=datetime.datetime(2000, 1, i+10, 12), datum=float(i+10))
          for i in range(0,n_days)
         ]
     for sesh in generic_sesh(variable_sesh, observations):
         yield sesh
예제 #3
0
 def obs_sesh(variable_sesh, var_temp_point, history_stn1_hourly):
     observations = [
         Obs(id=i, vars_id=var_temp_point.id, history_id=history_stn1_hourly.id,
             time=datetime.datetime(2000, 1, 1, i), datum=float(i))
         for i in range(0, 24)
         ]
     for sesh in generic_sesh(variable_sesh, observations):
         yield sesh
 def obs_sesh(variable_sesh, var_temp_point, history_stn1_hourly):
     observations = [
         Obs(variable=var_temp_point, history=history_stn1_hourly,
             time=datetime.datetime(2000, 1, 1, 12+i), datum=float(i))
         for i in range(1, 4)
     ]
     for sesh in generic_sesh(variable_sesh, observations):
         yield sesh
 def obs_sesh(variable_sesh, history_stn1_hourly, var_temp_point, var_temp_max, var_temp_min,
              var_temp_mean, var_foo):
     observations = []
     id = 0
     for var in [var_temp_point, var_temp_max, var_temp_min, var_temp_mean, var_foo]:
         for i in range(0,2):
             id += 1
             observations.append(Obs(variable=var, history=history_stn1_hourly,
                          time=datetime.datetime(2000, 1, 1, 12, id), datum=float(id)))
     for sesh in generic_sesh(variable_sesh, observations):
         yield sesh
예제 #6
0
 def obs_sesh(variable_sesh, var_temp_point, history_stn1_hourly):
     observations = []
     id = 0
     for day in days:
         for hour in hours:
             id += 1
             observations.append(
                 Obs(id=id, vars_id=var_temp_point.id, history_id=history_stn1_hourly.id,
                     time=datetime.datetime(2000, 1, day, hour), datum=float(hour))
             )
     for sesh in generic_sesh(variable_sesh , observations):
         yield sesh
예제 #7
0
 def obs_sesh(variable_sesh, var_temp_point, history_stn1_daily):
     observations = []
     id = 0
     for month in months:
         for day in days:
             id += 1
             observations.append(
                 Obs(id=id + 100, vars_id=var_temp_point.id, history_id=history_stn1_daily.id,
                     time=datetime.datetime(2000, month, day, 12), datum=float(id))
             )
     for sesh in generic_sesh(variable_sesh , observations):
         yield sesh
예제 #8
0
def view_test_session(mod_empty_view_session):
    for sesh in generic_sesh(mod_empty_view_session, [
        Description(id=1, desc='alpha'),
        Description(id=2, desc='beta'),
        Description(id=3, desc='gamma'),
        Thing(id=1, name='one', description_id=1),
        Thing(id=2, name='two', description_id=2),
        Thing(id=3, name='three', description_id=3),
        Thing(id=4, name='four', description_id=2),
        Thing(id=5, name='five', description_id=1),
    ]):
        yield sesh
 def obs_sesh(variable_sesh, var_temp_point, history_stn1_hourly, history_stn1_daily):
     # hourly observations
     observations = [
         Obs(variable=var_temp_point, history=history_stn1_hourly,
                   time=datetime.datetime(2000, 1, 1, 12+i), datum=float(i))
              for i in range(0, n_hours)
         ]
     # daily observation
     observations.append(Obs(variable=var_temp_point, history=history_stn1_daily,
                  time=datetime.datetime(2000, 1, 2, 12), datum=10.0))
     for sesh in generic_sesh(variable_sesh, observations):
         yield sesh
예제 #10
0
 def obs_sesh(variable_sesh, var_temp_point, history_stn1_hourly, var_temp_point2, history_stn2_hourly):
     observations = []
     id = 0
     for (var, hx) in [(var_temp_point, history_stn1_hourly), (var_temp_point2, history_stn2_hourly)]:
         for month in months:
             for day in days:
                 for hour in hours:
                     id += 1
                     observations.append(
                         Obs(id=id, vars_id=var.id, history_id=hx.id,
                             time=datetime.datetime(2000, month, day, hour), datum=float(id))
                     )
     for sesh in generic_sesh(variable_sesh , observations):
         yield sesh
                    def obs_sesh(variable_sesh, var_temp_max, var_temp_min, history_stn1_12_hourly):
                        observations = [Obs(variable=var_temp_max, history=history_stn1_12_hourly,
                                            time=datetime.datetime(2000, 1, day, hour), datum=float(temp))
                                        for day, hours in iter(tmax.items())
                                        for hour, temp in iter(hours.items())
                                       ] +\
                                       [Obs(variable=var_temp_min, history=history_stn1_12_hourly,
                                                time=datetime.datetime(2000, 1, day, hour), datum=float(temp))
                                        for day, hours in iter(tmin.items())
                                        for hour, temp in iter(hours.items())
                                       ]

                        for sesh in generic_sesh(variable_sesh, observations):
                            yield sesh
 def obs_sesh(variable_sesh, var_temp_point, history_stn1_hourly,
              var_temp_point2, history_stn2_hourly):
     observations = []
     id = 0
     for (var, hx) in [(var_temp_point, history_stn1_hourly),
                       (var_temp_point2, history_stn2_hourly)]:
         for day in range(1, n_days+1):
             for hour in range(0, n_hours):
                 id += 1
                 observations.append(
                     Obs(variable=var, history=hx,
                           time=datetime.datetime(2000, 1, day, 12+hour), datum=float(id))
                 )
     for sesh in generic_sesh(variable_sesh, observations):
         yield sesh
 def obs_sesh(request, variable_sesh, var_temp_point, var_precip_net1_1, history_stn1_hourly):
     """Yield a session with particular observations added to variable_sesh.
     Observations added depend on the value of request.param: 
     MonthlyAverageOfDailyMaxTemperature, MonthlyAverageOfDailyMinTemperature, or MonthlyTotalPrecipitation.
     This fixture is used as an indirect fixture for parametrized tests.
     """
     if request.param in [MonthlyAverageOfDailyMaxTemperature, MonthlyAverageOfDailyMinTemperature]:
         observations = [Obs(variable=var_temp_point, history=history_stn1_hourly,
                             time=datetime.datetime(2000, 1, day, hour), datum=float(hour))
                         for day in days for hour in hours]
     else:
         observations = [Obs(variable=var_precip_net1_1, history=history_stn1_hourly,
                             time=datetime.datetime(2000, 1, day, hour), datum=1.0)
                         for day in days for hour in hours]
     for sesh in generic_sesh(variable_sesh , observations):
         yield sesh
 def obs_sesh(request, variable_sesh, history_stn1_daily, var_temp_point, var_precip_net1_1):
     if request.param in [MonthlyAverageOfDailyMaxTemperature, MonthlyAverageOfDailyMinTemperature]:
         observations = [
             Obs(variable=var_temp_point, history=history_stn1_daily,
                 time=datetime.datetime(2000, month, day, 12), datum=float(day))
             for month in months
             for day in days
         ]
     else:
         observations = [
             Obs(variable=var_precip_net1_1, history=history_stn1_daily,
                 time=datetime.datetime(2000, month, day, 12), datum=1.0)
             for month in months
             for day in days
         ]
     for sesh in generic_sesh(variable_sesh , observations):
         yield sesh
예제 #15
0
 def obs_sesh(variable_sesh, var_temp_point, history_stn1_hourly):
     observations = [(Obs(id=1, vars_id=var_temp_point.id, history_id=history_stn1_hourly.id,
                      time=datetime.datetime(2000, 1, 1, 12), datum=1.0)), (
                 Obs(id=2, vars_id=var_temp_point.id, history_id=history_stn1_hourly.id,
                     time=datetime.datetime(2000, 1, 1, 13), datum=2.0)), (
                 Obs(id=3, vars_id=var_temp_point.id, history_id=history_stn1_hourly.id,
                     time=datetime.datetime(2000, 1, 1, 14), datum=3.0)), (
                 Obs(id=4, vars_id=var_temp_point.id, history_id=history_stn1_hourly.id,
                     time=datetime.datetime(2000, 1, 2, 12), datum=4.0)), (
                 Obs(id=5, vars_id=var_temp_point.id, history_id=history_stn1_hourly.id,
                     time=datetime.datetime(2000, 1, 2, 13), datum=5.0)), (
                 Obs(id=6, vars_id=var_temp_point.id, history_id=history_stn1_hourly.id,
                     time=datetime.datetime(2000, 1, 2, 14), datum=6.0)), (
                 Obs(id=7, vars_id=var_temp_point.id, history_id=history_stn1_hourly.id,
                     time=datetime.datetime(2000, 1, 2, 15), datum=7.0))]
     for sesh in generic_sesh(variable_sesh, observations):
         yield sesh
예제 #16
0
 def obs_sesh(variable_sesh, var_temp_max, var_temp_min, history_stn1_12_hourly):
     observations = []
     id = 0
     for day, hours in iter(tmax.items()):
         for hour, temp in iter(hours.items()):
             id += 1
             observations.append(
                 Obs(id=id, vars_id=var_temp_max.id, history_id=history_stn1_12_hourly.id,
                     time=datetime.datetime(2000, 1, day, hour), datum=float(temp))
             )
     for day, hours in iter(tmin.items()):
         for hour, temp in iter(hours.items()):
             id += 1
             observations.append(
                 Obs(id=id, vars_id=var_temp_min.id, history_id=history_stn1_12_hourly.id,
                     time=datetime.datetime(2000, 1, day, hour), datum=float(temp))
             )
     for sesh in generic_sesh(variable_sesh, observations):
         yield sesh
 def sesh_with_climate_baseline_values(sesh_with_station_and_history_records, histories):
     sesh = sesh_with_station_and_history_records
     variables = sesh.query(Variable)\
         .filter(Variable.network.has(name=pcic_climate_variable_network_name)) \
         .all()
     stations = sesh.query(Station).all()
     histories = [sesh.query(History)
                      .filter(History.station == station)
                      .order_by(History.sdate.desc())
                      .first()
                  for station in stations]
     derived_values = [
         DerivedValue(
             time=datetime.datetime(2000, month, monthrange(2000, month)[1], 23),
             datum=float(month),
             variable=variable,
             history=histories[h]
         )
         for variable in variables
         for h in range(2)
         for month in range(1, 13, h+1)  # a bit tricky: for history[1], leave out every other month
     ]
     for s in generic_sesh(sesh, derived_values):
         yield s
 def flag_sesh(obs_sesh, native_flag_discard, native_flag_non_discard,
               pcic_flag_discard, pcic_flag_non_discard):
     for sesh in generic_sesh(obs_sesh, [native_flag_discard, native_flag_non_discard,
                                         pcic_flag_discard, pcic_flag_non_discard]):
         yield sesh
def sesh_with_station_and_history_records(sesh_with_climate_baseline_variables, stations, histories):
    for sesh in generic_sesh(sesh_with_climate_baseline_variables, stations + histories):
        yield sesh
 def variable_sesh(history_sesh, var_temp_point):
     for sesh in generic_sesh(history_sesh , [var_temp_point]):
         yield sesh
def sesh_with_other_network_and_climatology_variables(session, other_network, other_climatology_variables):
    for sesh in generic_sesh(session, [other_network] + other_climatology_variables):
        yield sesh
 def history_sesh(station_sesh, history_stn1_hourly):
     for sesh in generic_sesh(station_sesh , [history_stn1_hourly]):
         yield sesh
 def station_sesh(network_sesh, station1):
     for sesh in generic_sesh(network_sesh , [station1]):
         yield sesh
 def network_sesh(with_views_sesh, network1):
     for sesh in generic_sesh(with_views_sesh , [network1]):
         yield sesh
 def variable_sesh(history_sesh, var_temp_max, var_temp_min):
     for sesh in generic_sesh(history_sesh, [var_temp_max, var_temp_min]):
         yield sesh
 def variable_sesh(history_sesh, var_temp_point, var_temp_max, var_temp_min, var_temp_mean, var_foo):
     for sesh in generic_sesh(history_sesh ,
                              [var_temp_point, var_temp_max, var_temp_min, var_temp_mean, var_foo]):
         yield sesh