def pick_winners_at_conference(): """Pick winers at regObs competition at nordic avalanche conference at Åndalsnes.""" import random as rand romsdalen_konf_obs = go.get_all_registrations('2017-11-02', '2017-11-05', region_ids=3023, geohazard_tids=10) romsdalen_konf_regs = go.get_data('2017-11-02', '2017-11-05', region_ids=3023, geohazard_tids=10, output='Nest') rauma_konf_obs = [] rauma_konf_regs = [] for o in romsdalen_konf_obs: if o.MunicipalName == 'RAUMA': rauma_konf_obs.append(o) for r in romsdalen_konf_regs: if r['MunicipalName'] == 'RAUMA': rauma_konf_regs.append(r) print('Antall obs: {}'.format(len(rauma_konf_regs))) print('Antall enkelt obs: {}'.format(len(rauma_konf_obs))) print('1 : {}'.format(rauma_konf_obs[rand.randint( 0, len(rauma_konf_obs))].NickName)) print('2 : {}'.format(rauma_konf_obs[rand.randint( 0, len(rauma_konf_obs))].NickName)) print('3 : {}'.format(rauma_konf_obs[rand.randint( 0, len(rauma_konf_obs))].NickName)) print('4 : {}'.format(rauma_konf_obs[rand.randint( 0, len(rauma_konf_obs))].NickName)) print('5 : {}'.format(rauma_konf_obs[rand.randint( 0, len(rauma_konf_obs))].NickName))
def total_2018_and_part_water(): from_date = dt.date(2018, 1, 1) to_date = dt.date(2018, 12, 31) all_observations = go.get_data(from_date, to_date, output='Count nest') all_water_observ = go.get_data(from_date, to_date, geohazard_tids=60, output='Count nest') all_snow_observ = go.get_data(from_date, to_date, geohazard_tids=10, output='Count nest') all_dirt_observ = go.get_data(from_date, to_date, geohazard_tids=[20, 30, 40], output='Count nest') all_ice_observ = go.get_data(from_date, to_date, geohazard_tids=70, output='Count nest') # all_observations_2016 = gvp.get_all_observations('2016') # all_forms_2016 = gvp.get_all_observations('2016', output='List') # # all_observations_2017 = gvp.get_all_observations('2017') # all_forms_2017 = gvp.get_all_observations('2017', output='List') # # all_observations_2018 = gvp.get_all_observations('2018') # all_forms_2018 = gvp.get_all_observations('2018', output='List') all_observations_2015_16 = gvp.get_all_observations('2015-16') all_forms_2015_16 = gvp.get_all_observations('2015-16', output='List') all_observations_2016_17 = gvp.get_all_observations('2016-17') all_forms_2016_17 = gvp.get_all_observations('2016-17', output='List') all_observations_2017_18 = gvp.get_all_observations('2017-18') all_forms_2017_18 = gvp.get_all_observations('2017-18', output='List') pass
def test_avalanche_activity_2(self): from_date, to_date = '2017-03-01', '2017-03-10' avalanche_activity_2 = go.get_avalanche_activity_2(from_date, to_date) avalanche_activity_2_df = go.get_avalanche_activity_2(from_date, to_date, output='DataFrame') avalanche_activity_2_count = go.get_avalanche_activity_2(from_date, to_date, output='Count') self.assertIsInstance(avalanche_activity_2[0], go.AvalancheActivityObs2) self.assertIsInstance(avalanche_activity_2_df, pd.DataFrame) avalanche_activity_2_obs = go.get_data(from_date, to_date, registration_types=33) self.assertEqual(avalanche_activity_2_count, len(avalanche_activity_2_obs))
# -*- coding: utf-8 -*- """This is an example of how varsomdata/getobservations.py may be used to get observations from regObs webapi - http://api.nve.no/doc/regobs-webapi/ It takes time to make requests. Progress can be followed in the log files. """ from varsomdata import getobservations as go import datetime as dt __author__ = 'raek' # One observation with a given ID may one_obs = go.get_data(reg_ids=130548) # If multiple id's wil be used, give them as list. Result may be returned as a list of forms (default) or # nested, i.e. all forms are listed under their respective observations. two_obs = go.get_data(reg_ids=[130548, 130328]) # A request may specify a time period and specific geohazards. # Snow is 10 and ice is 70. Water is 60. Dirt is [20, 30, 40] all_data_snow = go.get_data('2016-12-30', '2017-01-01', geohazard_tids=10) ice_data = go.get_data(from_date='2016-10-01', to_date='2016-11-01', geohazard_tids=70) # The data may be returned as a list of classes, as opposed to the default return in get_data which are dictionaries # raw as given on regObs webapi. data_as_classes = go.get_all_observations('2018-05-01', '2018-08-01') # We may get observation forms directly. Note, from and to date are first and may also be given as # positional arguments, even though Is recommend keyword arguments. land_slides = go.get_land_slide_obs('2018-01-01', '2018-02-01')
# -*- coding: utf-8 -*- """This is an example of how varsomdata/getobservations.py may be used to get observations from regObs webapi - http://api.nve.no/doc/regobs-webapi/ It takes time to make requests. Progress can be followed in the log files. """ from varsomdata import getobservations as go import datetime as dt __author__ = 'raek' # One observation with a given ID may one_obs = go.get_data(reg_ids=130548) # If multiple id's wil be used, give them as list. Result may be returned as a list of forms (default) or # nested, i.e. all forms are listed under their respective observations. two_obs = go.get_data(reg_ids=[130548, 130328], output='Nest') # A request may specify a time period and specific geohazards. # Snow is 10 and ice is 70. Water is 60. Dirt is [20, 30, 40] all_data_snow = go.get_data('2016-12-30', '2017-01-01', geohazard_tids=10) ice_data = go.get_data(from_date='2016-10-01', to_date='2016-11-01', geohazard_tids=70, output='Nest') # The data may be returned as a list of classes, as opposed to the default return in get_data which are dictionaries # raw as given on regObs webapi. data_as_classes = go.get_data_as_class('2018-05-01', '2018-08-01')
def get_elevation(_id): # utility function used in "add_metadata" _obs = go.get_data(reg_ids=_id) return _obs[0]['ObsLocation']['Height']