<s> ClimateDataPortal = local_import ( '<STR_LIT>' ) <EOL> def clear_tables ( ) : <EOL> ClimateDataPortal . place . truncate ( ) <EOL> ClimateDataPortal . rainfall_mm . truncate ( ) <EOL> ClimateDataPortal . temperature_celsius . truncate ( ) <EOL> db . commit ( ) <EOL> def frange ( start , end , inc = <NUM_LIT:1.0> ) : <EOL> value = start <EOL> i = <NUM_LIT:0> <EOL> while True : <EOL> value = start + ( i * inc ) <EOL> if value >= end : <EOL> raise StopIteration <EOL> else : <EOL> yield value <EOL> i += <NUM_LIT:1> <EOL> def populate_test_climate_data ( ) : <EOL> assert session . s3 . debug == True <EOL> db . commit ( ) <EOL> place_id_grid = [ ] <EOL> for latitude in frange ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) : <EOL> row = [ ] <EOL> for longitude in frange ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) : <EOL> place_id = ClimateDataPortal . place . insert ( <EOL> longitude = longitude , <EOL> latitude = latitude <EOL> ) <EOL> row . append ( place_id ) <EOL> place_id_grid . append ( row ) <EOL> def to_date ( month_number ) : <EOL> return datetime . date ( <EOL> month_number / <NUM_LIT:12> , <EOL> ( month_number % <NUM_LIT:12> ) + <NUM_LIT:1> , <EOL> <NUM_LIT:1> <EOL> ) <EOL> time_period_ids = list ( range ( <EOL> ClimateDataPortal . date_to_month_number ( datetime . date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) , <EOL> ClimateDataPortal . date_to_month_number ( datetime . date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) , <EOL> ) ) <EOL> from random import randint <EOL> observation_place_ids = set ( ) <EOL> for i in range ( <NUM_LIT:100> ) : <EOL> random_row = place_id_grid [ <EOL> randint ( <NUM_LIT:0> , len ( place_id_grid ) - <NUM_LIT:1> ) <EOL> ] <EOL> random_place = random_row [ <EOL> randint ( <NUM_LIT:0> , len ( random_row ) - <NUM_LIT:1> ) <EOL> ] <EOL> observation_place_ids . add ( random_place ) <EOL> for observation_place_id in observation_place_ids : <EOL> for time_period_id in time_period_ids : <EOL> ClimateDataPortal . rainfall_mm . insert ( <EOL> place_id = observation_place_id , <EOL> time_period = time_period_id , <EOL> sample_type = ClimateDataPortal . Observed , <EOL> value = randint ( <NUM_LIT:50> , <NUM_LIT> ) <EOL> ) <EOL> ClimateDataPortal . temperature_celsius . insert ( <EOL> place_id = observation_place_id , <EOL> time_period = time_period_id , <EOL> sample_type = ClimateDataPortal . Observed , <EOL> value = randint ( - <NUM_LIT:30> , <NUM_LIT:30> ) <EOL> ) <EOL> db . commit ( ) <EOL> map_plugin = ClimateDataPortal . MapPlugin ( <EOL> data_type_option_names = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> parameter_type_names = [ '<STR_LIT>' , '<STR_LIT>' , ] , <EOL> year_max = datetime . date . today ( ) . year , <EOL> year_min = <NUM_LIT> , <EOL> ) <EOL> """<STR_LIT>""" </s>
