Beispiel #1
0
def harvest_and_save_blindern(from_string, to_string):

    stnr_met_blind = 18700          # Blindern (met)
    from_date = dt.datetime.strptime(from_string, "%Y-%m-%d")
    to_date = dt.datetime.strptime(to_string, "%Y-%m-%d")
    #elems_blind = gws.getElementsFromTimeserieTypeStation(stnr_met_blind, 2, output='csv')

    rr = gws.getMetData(stnr_met_blind, 'RR', from_date, to_date, 0, output='raw list')
    rr = we.millimeter_from_meter(rr)
    rr_test_message = we.test_for_missing_elements(rr, from_date, to_date)

    tam = gws.getMetData(stnr_met_blind, 'TAM', from_date, to_date, 0, output='raw list')
    tam_test_message = we.test_for_missing_elements(tam, from_date, to_date)

    nnm = gws.getMetData(stnr_met_blind, 'NNM', from_date, to_date, 0, output='raw list')
    nnm_test_message = we.test_for_missing_elements(nnm, from_date, to_date)

    file_name = '{2}RR TAM NNM Blindern 18700 {0} to {1}.txt'.format(from_string, to_string, env.data_path)

    WSYS = "github/Ice-modelling/rundataharvester.py"
    OPER = "Ragnar Ekker"
    DCHA = ['RR  [mm/day]          on Blindern 18700 from eklima.met.no',
            'TAM [C]     daily avg on Blindern 18700 from eklima.met.no',
            'NNM [%/100] daily avg on Blindern 18700 from eklima.met.no']

    mfd.write_vardat2(file_name, [rr, tam, nnm], WSYS, OPER, DCHA)

    return
Beispiel #2
0
def harvest_and_save_nordnesfjelet(from_string, to_string):

    stnr = 91500          # Nordnesfjellet (met)
    from_date = dt.datetime.strptime(from_string, "%Y-%m-%d")
    to_date = dt.datetime.strptime(to_string, "%Y-%m-%d")
    #elems_blind = gws.getElementsFromTimeserieTypeStation(stnr, 2, output='csv')

    qli = gws.getMetData(stnr, 'QLI', from_date, to_date, 2, output='raw list')
    qli_test_message = we.test_for_missing_elements(qli, from_date, to_date, time_step=60*60)

    ta = gws.getMetData(stnr, 'ta', from_date, to_date, 2, output='raw list')
    ta_test_message = we.test_for_missing_elements(ta, from_date, to_date, time_step=3600)

    rr_1 = gws.getMetData(stnr, 'rr_1', from_date, to_date, 2, output='raw list')
    rr_1 = we.millimeter_from_meter(rr_1)
    rr_test_message = we.test_for_missing_elements(rr_1, from_date, to_date, time_step=3600)

    file_name = '{2}QLI TA RR Nordnesfjellet 91500 {0} to {1}.txt'.format(from_string, to_string, env.data_path)

    WSYS = "github/Ice-modelling/rundataharvester.py"
    OPER = "Ragnar Ekker"
    DCHA = ['QLI  [Wh/m2] avg pr hr on Nordnesfjellet 91500 from eklima.met.no',
            'TA   [C]     avg pr hr on Nordnesfjellet 91500 from eklima.met.no',
            'RR_1 [mm/hr]           on Nordnesfjellet 91500 from eklima.met.no']

    mfd.write_vardat2(file_name, [qli, ta, rr_1], WSYS, OPER, DCHA)

    return
Beispiel #3
0
def harvest_and_save_blindern(from_string, to_string):

    stnr_met_blind = 18700  # Blindern (met)
    from_date = dt.datetime.strptime(from_string, "%Y-%m-%d")
    to_date = dt.datetime.strptime(to_string, "%Y-%m-%d")
    #elems_blind = gws.getElementsFromTimeserieTypeStation(stnr_met_blind, 2, output='csv')

    rr = gws.getMetData(stnr_met_blind,
                        'RR',
                        from_date,
                        to_date,
                        0,
                        output='raw list')
    rr = we.millimeter_from_meter(rr)
    rr_test_message = we.test_for_missing_elements(rr, from_date, to_date)

    tam = gws.getMetData(stnr_met_blind,
                         'TAM',
                         from_date,
                         to_date,
                         0,
                         output='raw list')
    tam_test_message = we.test_for_missing_elements(tam, from_date, to_date)

    nnm = gws.getMetData(stnr_met_blind,
                         'NNM',
                         from_date,
                         to_date,
                         0,
                         output='raw list')
    nnm_test_message = we.test_for_missing_elements(nnm, from_date, to_date)

    file_name = '{2}RR TAM NNM Blindern 18700 {0} to {1}.txt'.format(
        from_string, to_string, env.data_path)

    WSYS = "github/Ice-modelling/rundataharvester.py"
    OPER = "Ragnar Ekker"
    DCHA = [
        'RR  [mm/day]          on Blindern 18700 from eklima.met.no',
        'TAM [C]     daily avg on Blindern 18700 from eklima.met.no',
        'NNM [%/100] daily avg on Blindern 18700 from eklima.met.no'
    ]

    mfd.write_vardat2(file_name, [rr, tam, nnm], WSYS, OPER, DCHA)

    return
Beispiel #4
0
def harvest_and_save_nordnesfjelet(from_string, to_string):

    stnr = 91500  # Nordnesfjellet (met)
    from_date = dt.datetime.strptime(from_string, "%Y-%m-%d")
    to_date = dt.datetime.strptime(to_string, "%Y-%m-%d")
    #elems_blind = gws.getElementsFromTimeserieTypeStation(stnr, 2, output='csv')

    qli = gws.getMetData(stnr, 'QLI', from_date, to_date, 2, output='raw list')
    qli_test_message = we.test_for_missing_elements(qli,
                                                    from_date,
                                                    to_date,
                                                    time_step=60 * 60)

    ta = gws.getMetData(stnr, 'ta', from_date, to_date, 2, output='raw list')
    ta_test_message = we.test_for_missing_elements(ta,
                                                   from_date,
                                                   to_date,
                                                   time_step=3600)

    rr_1 = gws.getMetData(stnr,
                          'rr_1',
                          from_date,
                          to_date,
                          2,
                          output='raw list')
    rr_1 = we.millimeter_from_meter(rr_1)
    rr_test_message = we.test_for_missing_elements(rr_1,
                                                   from_date,
                                                   to_date,
                                                   time_step=3600)

    file_name = '{2}QLI TA RR Nordnesfjellet 91500 {0} to {1}.txt'.format(
        from_string, to_string, env.data_path)

    WSYS = "github/Ice-modelling/rundataharvester.py"
    OPER = "Ragnar Ekker"
    DCHA = [
        'QLI  [Wh/m2] avg pr hr on Nordnesfjellet 91500 from eklima.met.no',
        'TA   [C]     avg pr hr on Nordnesfjellet 91500 from eklima.met.no',
        'RR_1 [mm/hr]           on Nordnesfjellet 91500 from eklima.met.no'
    ]

    mfd.write_vardat2(file_name, [qli, ta, rr_1], WSYS, OPER, DCHA)

    return
Beispiel #5
0
def harvest_for_mylake_hakkloa(from_string, to_string):
    """Method gathers meteorological parameters needed to run myLake on Hakkloa and saves them to a
    formatted file as needed to run myLake. For columns needed se MyLakeInput class.

    :param from_string:     {string}    from date to acquire data
    :param to_string:       {string}    to date to acquire data
    :return:

    HydraII parameters:
        Wind                15
        Temperature         17
        Relative humidity    2
    """

    utm33_x = 259942                # Hakloa (buoy)
    utm33_y = 6671218               # Hakloa (buoy)
    stnr_met_blind = 18700          # Blindern (met)
    stnr_met_bjorn = 18500          # Bjørnholt (met)
    stnr_nve = '6.24.4'             # Hakloa (NVE)

    hydraii_temperature = '{0}6.24.4.17.1 Hakkloa temperatur 20110101-20151009.txt'.format(env.data_path)
    hydraii_wind = '{0}6.24.4.15.1 Hakkloa vind 20110101-20151009.txt'.format(env.data_path)
    hydraii_relative_humidity = '{0}6.24.4.2.1 Hakkloa relativ fuktighet 20110101-20151009.txt'.format(env.data_path)

    from_date = dt.datetime.strptime(from_string, "%Y-%m-%d")
    to_date = dt.datetime.strptime(to_string, "%Y-%m-%d")
    data = MyLakeInput(from_date, to_date)
    data.output_file_path = '{0}HAK_input'.format(env.data_path)
    data.output_header = 'MyLake model input data for Hakkloa from Hakkloa (NVE), Bjørnholt (met) and Blindern (met) stations'

    data.add_Global_rad(we.constant_weather_element('Hakkloa', from_date, to_date, 'Global_rad', None))
    data.add_Cloud_cov(gws.getMetData(stnr_met_blind, 'NNM', from_date, to_date, 0))
    data.add_Air_temp(gfd.read_hydra_time_value(stnr_nve, '17.1', hydraii_temperature, from_date, to_date))
    data.add_Relat_hum(gfd.read_hydra_time_value(stnr_nve, '2.1', hydraii_relative_humidity, from_date, to_date))
    data.add_Air_press(gws.getMetData(stnr_met_blind, 'POM', from_date, to_date, 0))
    data.add_Wind_speed(gfd.read_hydra_time_value(stnr_nve, '15.1', hydraii_wind, from_date, to_date))
    data.add_Precipitation(we.millimeter_from_meter(gws.getMetData(stnr_met_bjorn, 'RR', from_date, to_date, 0)))

    # Inflow is water shed area * precipitation
    Inflow = []
    precipitation = data.Precipitation # precipitation in [mm]
    water_shed_area = 6.49 * 10**6 # [m2]
    for p in precipitation:
        value =  p.Value/1000*water_shed_area
        Inflow.append(we.WeatherElement('Hakkloa', p.Date, 'Inflow', value))
    data.add_Inflow(Inflow)

    # Inflow temperature is assumed air temp but never below 0C and if snow always 0C
    snow = gcs.getGriddata(utm33_x, utm33_y, 'sd', from_date, to_date)
    temperature = data.Air_temp

    #mfd.write_weather_element_list(temperature)
    #mfd.write_weather_element_list(snow)
    #mfd.write_weather_element_list(data.Relat_hum)
    #mfd.write_weather_element_list(data.Wind_speed)

    Inflow_T = []
    for i in range(0, len(snow), 1):
        date = temperature[i].Date
        value = max(0., temperature[i].Value)       # water never below 0C
        if snow[i].Value > 0. and value > 0.:       # if snow, water never over 0C
            value = 0.
        Inflow_T.append(we.WeatherElement('Hakkloa', date, 'Inflow_T', value))
    data.add_Inflow_T(Inflow_T)

    data.add_Inflow_C(we.constant_weather_element('Hakkloa', from_date, to_date, 'Inflow_C', .5))
    data.add_Inflow_S(we.constant_weather_element('Hakkloa', from_date, to_date, 'Inflow_S', .01))
    data.add_Inflow_TP(we.constant_weather_element('Hakkloa', from_date, to_date, 'Inflow_TP', 44.))
    data.add_Inflow_DOP(we.constant_weather_element('Hakkloa', from_date, to_date, 'Inflow_DOP', 7.))
    data.add_Inflow_Chla(we.constant_weather_element('Hakkloa', from_date, to_date, 'Inflow_Chla', .1))
    data.add_Inflow_DOC(we.constant_weather_element('Hakkloa', from_date, to_date, 'Inflow_DOC', 3000.))

    return data
Beispiel #6
0
def harvest_for_mylake_hakkloa(from_string, to_string):
    """Method gathers meteorological parameters needed to run myLake on Hakkloa and saves them to a
    formatted file as needed to run myLake. For columns needed se MyLakeInput class.

    :param from_string:     {string}    from date to acquire data
    :param to_string:       {string}    to date to acquire data
    :return:

    HydraII parameters:
        Wind                15
        Temperature         17
        Relative humidity    2
    """

    utm33_x = 259942  # Hakloa (buoy)
    utm33_y = 6671218  # Hakloa (buoy)
    stnr_met_blind = 18700  # Blindern (met)
    stnr_met_bjorn = 18500  # Bjørnholt (met)
    stnr_nve = '6.24.4'  # Hakloa (NVE)

    hydraii_temperature = '{0}6.24.4.17.1 Hakkloa temperatur 20110101-20151009.txt'.format(
        env.data_path)
    hydraii_wind = '{0}6.24.4.15.1 Hakkloa vind 20110101-20151009.txt'.format(
        env.data_path)
    hydraii_relative_humidity = '{0}6.24.4.2.1 Hakkloa relativ fuktighet 20110101-20151009.txt'.format(
        env.data_path)

    from_date = dt.datetime.strptime(from_string, "%Y-%m-%d")
    to_date = dt.datetime.strptime(to_string, "%Y-%m-%d")
    data = MyLakeInput(from_date, to_date)
    data.output_file_path = '{0}HAK_input'.format(env.data_path)
    data.output_header = 'MyLake model input data for Hakkloa from Hakkloa (NVE), Bjørnholt (met) and Blindern (met) stations'

    data.add_Global_rad(
        we.constant_weather_element('Hakkloa', from_date, to_date,
                                    'Global_rad', None))
    data.add_Cloud_cov(
        gws.getMetData(stnr_met_blind, 'NNM', from_date, to_date, 0))
    data.add_Air_temp(
        gfd.read_hydra_time_value(stnr_nve, '17.1', hydraii_temperature,
                                  from_date, to_date))
    data.add_Relat_hum(
        gfd.read_hydra_time_value(stnr_nve, '2.1', hydraii_relative_humidity,
                                  from_date, to_date))
    data.add_Air_press(
        gws.getMetData(stnr_met_blind, 'POM', from_date, to_date, 0))
    data.add_Wind_speed(
        gfd.read_hydra_time_value(stnr_nve, '15.1', hydraii_wind, from_date,
                                  to_date))
    data.add_Precipitation(
        we.millimeter_from_meter(
            gws.getMetData(stnr_met_bjorn, 'RR', from_date, to_date, 0)))

    # Inflow is water shed area * precipitation
    Inflow = []
    precipitation = data.Precipitation  # precipitation in [mm]
    water_shed_area = 6.49 * 10**6  # [m2]
    for p in precipitation:
        value = p.Value / 1000 * water_shed_area
        Inflow.append(we.WeatherElement('Hakkloa', p.Date, 'Inflow', value))
    data.add_Inflow(Inflow)

    # Inflow temperature is assumed air temp but never below 0C and if snow always 0C
    snow = gcs.getGriddata(utm33_x, utm33_y, 'sd', from_date, to_date)
    temperature = data.Air_temp

    #mfd.write_weather_element_list(temperature)
    #mfd.write_weather_element_list(snow)
    #mfd.write_weather_element_list(data.Relat_hum)
    #mfd.write_weather_element_list(data.Wind_speed)

    Inflow_T = []
    for i in range(0, len(snow), 1):
        date = temperature[i].Date
        value = max(0., temperature[i].Value)  # water never below 0C
        if snow[i].Value > 0. and value > 0.:  # if snow, water never over 0C
            value = 0.
        Inflow_T.append(we.WeatherElement('Hakkloa', date, 'Inflow_T', value))
    data.add_Inflow_T(Inflow_T)

    data.add_Inflow_C(
        we.constant_weather_element('Hakkloa', from_date, to_date, 'Inflow_C',
                                    .5))
    data.add_Inflow_S(
        we.constant_weather_element('Hakkloa', from_date, to_date, 'Inflow_S',
                                    .01))
    data.add_Inflow_TP(
        we.constant_weather_element('Hakkloa', from_date, to_date, 'Inflow_TP',
                                    44.))
    data.add_Inflow_DOP(
        we.constant_weather_element('Hakkloa', from_date, to_date,
                                    'Inflow_DOP', 7.))
    data.add_Inflow_Chla(
        we.constant_weather_element('Hakkloa', from_date, to_date,
                                    'Inflow_Chla', .1))
    data.add_Inflow_DOC(
        we.constant_weather_element('Hakkloa', from_date, to_date,
                                    'Inflow_DOC', 3000.))

    return data