Exemple #1
0
def __test_clouds_from_short_wave():

    import getWSklima as gws
    import weather as we

    date_list = [dt.date.today() - dt.timedelta(days=x) for x in range(0, 365)]
    date_list = [
        dt.datetime.combine(d, dt.datetime.min.time()) for d in date_list
    ]
    date_list.reverse()

    # test Nordnesfjellet i Troms
    station_id = 91500
    short_wave_id = 'QSI'
    long_wave_id = 'QLI'
    temperature_id = 'TA'
    timeseries_type = 2
    utm_e = 711075
    utm_n = 7727719

    short_wave = gws.getMetData(station_id, short_wave_id, date_list[0],
                                date_list[-1], timeseries_type)
    long_wave = gws.getMetData(station_id, long_wave_id, date_list[0],
                               date_list[-1], timeseries_type)
    temperature = gws.getMetData(station_id, temperature_id, date_list[0],
                                 date_list[-1], timeseries_type)

    short_wave = we.fix_data_quick(short_wave)
    long_wave = we.fix_data_quick(long_wave)
    temperature_daily = we.fix_data_quick(temperature)

    short_wave_daily = we.make_daily_average(short_wave)
    short_wave_daily = we.multiply_constant(
        short_wave_daily,
        24 * 3600 / 1000)  # Wh/m2 * 3600 s/h * kJ/1000J (energy) over 24hrs
    long_wave_daily = we.make_daily_average(long_wave)
    long_wave_daily = we.multiply_constant(long_wave_daily, 24 * 3600 / 1000)
    temperature_daily = we.make_daily_average(temperature)

    Short_wave_list = we.strip_metadata(short_wave_daily)
    I_clear_sky_list = [
        irradiance_clear_sky(utm_e, utm_n, d) for d in date_list
    ]
    Cloud_cover = clouds_from_short_wave(utm_e, utm_n, Short_wave_list,
                                         date_list)

    import matplotlib.pyplot as plt

    plt.plot(date_list, Short_wave_list)
    plt.plot(date_list, I_clear_sky_list)
    plt.plot(date_list, Cloud_cover)
    plt.ylim(0, 50000)
    plt.show()
Exemple #2
0
def __test_clouds_from_short_wave():

    import getWSklima as gws
    import weather as we

    date_list = [dt.date.today() - dt.timedelta(days=x) for x in range(0, 365)]
    date_list = [dt.datetime.combine(d, dt.datetime.min.time()) for d in date_list]
    date_list.reverse()

    # test Nordnesfjellet i Troms
    station_id = 91500
    short_wave_id = 'QSI'
    long_wave_id = 'QLI'
    temperature_id = 'TA'
    timeseries_type = 2
    utm_e = 711075
    utm_n = 7727719

    short_wave = gws.getMetData(station_id, short_wave_id, date_list[0], date_list[-1], timeseries_type)
    long_wave = gws.getMetData(station_id, long_wave_id, date_list[0], date_list[-1], timeseries_type)
    temperature = gws.getMetData(station_id, temperature_id, date_list[0], date_list[-1], timeseries_type)

    short_wave = we.fix_data_quick(short_wave)
    long_wave = we.fix_data_quick(long_wave)
    temperature_daily = we.fix_data_quick(temperature)

    short_wave_daily = we.make_daily_average(short_wave)
    short_wave_daily = we.multiply_constant(short_wave_daily, 24 * 3600 / 1000)  # Wh/m2 * 3600 s/h * kJ/1000J (energy) over 24hrs
    long_wave_daily = we.make_daily_average(long_wave)
    long_wave_daily = we.multiply_constant(long_wave_daily, 24 * 3600 / 1000)
    temperature_daily = we.make_daily_average(temperature)

    Short_wave_list = we.strip_metadata(short_wave_daily)
    I_clear_sky_list = [irradiance_clear_sky(utm_e, utm_n, d) for d in date_list]
    Cloud_cover = clouds_from_short_wave(utm_e, utm_n, Short_wave_list, date_list)

    import matplotlib.pyplot as plt

    plt.plot(date_list, Short_wave_list)
    plt.plot(date_list, I_clear_sky_list)
    plt.plot(date_list, Cloud_cover)
    plt.ylim(0, 50000)
    plt.show()
Exemple #3
0
def read_hydra_time_value(station,
                          element,
                          file_name,
                          from_date=None,
                          to_date=None,
                          timeseries_type=0):
    """Reads a time/value file made in NVEs Start for accessing data in HydraII.

    :param station:
    :param element:
    :param file_name:
    :param from_date:           {datetime} method returns [fromDate , toDate>
    :param to_date:             {datetime} method returns [fromDate , toDate>
    :param timeseries_type:
    :return:
    """

    print "getFildata.py -> read_hydra_time_value: Reading {0}".format(
        file_name)

    if from_date is None:
        from_date = dt.date(0, 0, 0)
    if to_date is None:
        to_date = dt.datetime.now().date()

    inn_file = open(file_name)
    inn_data = inn_file.readlines()
    inn_file.close()
    separator = ' '
    for i in range(len(inn_data)):
        inn_data[i] = inn_data[i].strip()  # get rid of ' ' and '\n' and such
        inn_data[i] = inn_data[i].split(
            separator)  # splits line into list of elements in the line

    weather_element_list = []
    for d in inn_data:
        if d[0] == '':  # blank line at end of file
            break
        value = float(d[1])
        date = dt.datetime.strptime(d[0], '%Y%m%d/%H%M')
        if from_date.date() <= date.date() < to_date.date():
            weather_element_list.append(
                we.WeatherElement(station, date, element, value))

    if timeseries_type == -1:  # do nothing
        weather_element_list = weather_element_list
    elif timeseries_type == 0:  # make daily averages of hourly values
        weather_element_list = we.make_daily_average(weather_element_list)
    else:
        print('no valid time series type selected')
        weather_element_list = 'no valid time series type selected'

    return weather_element_list
Exemple #4
0
def read_hydra_time_value(station, element, file_name, from_date=None, to_date=None, timeseries_type=0):
    """Reads a time/value file made in NVEs Start for accessing data in HydraII.

    :param station:
    :param element:
    :param file_name:
    :param from_date:           {datetime} method returns [fromDate , toDate>
    :param to_date:             {datetime} method returns [fromDate , toDate>
    :param timeseries_type:
    :return:
    """

    print "getFildata.py -> read_hydra_time_value: Reading {0}".format(file_name)

    if from_date is None:
        from_date = dt.date(0,0,0)
    if to_date is None:
        to_date = dt.datetime.now().date()

    inn_file = open(file_name)
    inn_data = inn_file.readlines()
    inn_file.close()
    separator = ' '
    for i in range(len(inn_data)):
        inn_data[i] = inn_data[i].strip()               # get rid of ' ' and '\n' and such
        inn_data[i] = inn_data[i].split(separator)      # splits line into list of elements in the line

    weather_element_list = []
    for d in inn_data:
        if d[0] == '':                  # blank line at end of file
            break
        value = float(d[1])
        date = dt.datetime.strptime(d[0], '%Y%m%d/%H%M')
        if from_date.date() <= date.date() < to_date.date():
            weather_element_list.append(we.WeatherElement(station, date, element, value))

    if timeseries_type == -1:                           # do nothing
        weather_element_list = weather_element_list
    elif timeseries_type == 0:                          # make daily averages of hourly values
        weather_element_list = we.make_daily_average(weather_element_list)
    else:
        print('no valid time series type selected')
        weather_element_list = 'no valid time series type selected'

    return weather_element_list
Exemple #5
0
def getGriddata(UTM33X, UTM33Y, elementID, fromDate, toDate, timeseries_type=0, output='list'):
    """Method gets data from the chartserver api at NVE. Method called is ShowData.aspx.
    Future dates as well as past dates are returned. Future dates are generated from model grids from met.no

    Note that griddata is based on met data from 00 to 06 dayly values. Eg. precipitation on 17th of mai is found in
    data for 06:00 18th of mai.

    Method returns [fromDate,toDate>

    :param UTM33X:          {int} X coordinate in utm33N
    :param UTM33Y:          {int} Y coordinate in utm33N
    :param elementID:       {string} Element ID in seNorge. Ex: elementID = 'fsw' is 24hr new snow depth in [cm]
    :param fromDate:        {datetime} method returns data [fromDate, toDate>
    :param toDate:          {datetime} method returns data [fromDate, toDate>
    :param timeseries_type  {int} Works only on output='list' daily = 0, no change = None (default)
    :param output:          {string} How to present the output.
    :return:                {list} List of WeatherElement objects with 24h resolution.

    Timeseries types:
        None                Data returned as received from service
        0                   Data made to daily average
        See also:           http://eklima.no/wsKlima/complete/cTimeserie_en.html

    Output options:
        'list':             returns a list of WeatherElement objects.
        'json':             returns NULL but saves a .json file til the working folder.


    ElementID's used:
        fws:                new snow last 24hrs
        sd:                 snow depth
        tm:                 temperature avarage 24hrs


    Example URL for getting grid data
        http://h-web01.nve.no/chartserver/ShowData.aspx?req=getchart
        &ver=1.0
        &vfmt=json
        &time=20141204T0000;20141212T0000
        &chd=ds=hgts,da=29,id=260151;6671132;fsw

    """

    url = '{0}&time={1};{2}&chd=ds=hgts,da=29,id={3};{4};{5}'.format(
        baseURL, fromDate.strftime('%Y%m%dT%H%M'), toDate.strftime('%Y%m%dT%H%M'), UTM33X, UTM33Y, elementID)

    if output == 'list':

        weatherElementList = make_weather_element_list_from_url(url , 'UTM33 X{0} Y{1}'.format(UTM33X, UTM33Y), elementID, {'MethodName': 'Chartserver - getGriddata'})

        # If to much data is requested, break it down to smaller portions.
        if weatherElementList == "Request less data.":
            time_delta = toDate - fromDate
            date_in_middle = (fromDate + time_delta/2).replace(hour=0, minute=0)
            weatherElementList = \
                getGriddata(UTM33X, UTM33Y, elementID, fromDate, date_in_middle, timeseries_type=timeseries_type, output=output) \
                + getGriddata(UTM33X, UTM33Y, elementID, date_in_middle, toDate, timeseries_type=timeseries_type, output=output)
            return weatherElementList

        else:

            if elementID == 'fsw' or elementID == 'sd':
                weatherElementList = meter_from_centimeter(weatherElementList)        # convert for [cm] til [m]

            if timeseries_type == -1:              # do nothing
                weatherElementList = weatherElementList
            elif timeseries_type == 0:                # make dailyavaregs of hourly values
                weatherElementList = make_daily_average(weatherElementList)
            else:
                print('no valid timeseries type selected')
                weatherElementList = 'no valid timeseries type selected'
            return weatherElementList

    elif output == 'json':
        datareq = requests.get(url)
        filename = 'X{0}_Y{1}_{2}.{3}_{4}.json'.format(
            UTM33X, UTM33Y, elementID, fromDate.strftime('%Y%m%d'), toDate.strftime('%Y%m%d'))
        f = open(filename, 'w')
        f.write((datareq.text).encode('utf-8'))
        f.close()
        return

    else:
        print('No valid output requested.')
        return 'No valid output requested'
Exemple #6
0
def getStationdata(stationID, elementID, fromDate, toDate, timeseries_type=0, output='list'):
    """Method gets data from the chartserver api at NVE. Method called is ShowData.aspx.
    The data returned from the api are 30min values but they may be recalculated to daily average in this method
    if timeseries_type=0. Method returns [fromDate,toDate>. Future dates are truncated in this method,
    but dataset may be complemented with the getYrdata in this class.

    :param stationID:   {string} Station ID in hydra. Ex: stationID  = '6.24.4'
    :param elementID:   {string} Element ID in hydra. Ex: elementID = '17.1'
    :param fromDate:    {datetime} method returns [fromDate ,toDate>
    :param toDate:      {datetime} method returns [fromDate ,toDate>
    :param output:      {string} How to present the output.
    :return:            {list} List of WeatherElement objects.


    Timeseries types:
        None                Data returned as received from service
        0                   Data made to daily average
        See also:           http://eklima.no/wsKlima/complete/cTimeserie_en.html

    Output options:
        'list':         returns a list of WeatherElement objects.
        'json':         returns NULL but saves a .json file til the working folder.

    URL for getting stationdata from Hakkloa 6.24.4.17.1

        http://h-web01.nve.no/chartserver/ShowData.aspx
        ?req=getchart
        &ver=1.0
        &vfmt=json
        &time=20141204T0000;20141212T0000
        &chd=ds=htsr,da=29,id=6.24.4.17.1

    """

    url = "{0}&time={1};{2}&chd=ds=htsr,da=29,id={3}.{4}"\
        .format(baseURL, fromDate.strftime('%Y%m%dT%H%M'), toDate.strftime('%Y%m%dT%H%M'), stationID, elementID)

    if output == 'list':
        weatherElementList = make_weather_element_list_from_url(url, stationID, elementID, {'MethodName': 'Chartserver - getStationdata'})

        # If to much data is requested, break it down to smaller portions.
        if weatherElementList == "Request less data.":
            time_delta = toDate - fromDate
            date_in_middle = (fromDate + time_delta/2).replace(hour=0, minute=0)
            weatherElementList = getStationdata(stationID, elementID, fromDate, date_in_middle, timeseries_type=timeseries_type, output=output) \
                                 + getStationdata(stationID, elementID, date_in_middle, toDate, timeseries_type=timeseries_type, output=output)
            return weatherElementList

        else:
            if timeseries_type == -1:              # do nothing
                weatherElementList = weatherElementList
            elif timeseries_type == 0:                # make daily averages of hourly values
                weatherElementList = make_daily_average(weatherElementList)
            else:
                print('no valid timeseries type selected')
                weatherElementList = 'no valid timeseries type selected'
            return weatherElementList

    elif output == 'json':
        datareq = requests.get(url)
        filename = '{0}.{1}_{2}_{3}.json'\
            .format(stationID, elementID, fromDate.strftime('%Y%m%d'), datetime.date.today().strftime('%Y%m%d'))
        f = open(filename, 'w')
        f.write((datareq.text).encode('utf-8'))
        f.close()
        return

    else:
        print('No valid output requested.')
        return 'No valid output requested'
Exemple #7
0
def getYrdata(stationID, elementID, fromDate, toDate, timeseries_type=0, output='list'):
    """
    Gets data form yr.no though the chartserver api at NVE. Method called is ShowData.aspx.
    Does not return historical values. Seems only to return +48 hrs even though more is requested.

    :param stationID:   {string} Station ID in hydra. Ex: stationID  = '6.24.4'
    :param elementID:   {string} Element ID in hydra. Ex: elementID = '17.1'
    :param fromDate:    {datetime} method returns data including fromDate
    :param toDate:      {datetime} method returns data including toDate
    :param output:      {string} How to present the output.
    :return:            List of WeatherElement objects with 24h resolution.


    Timeseries types:
        None                Data returned as received from service
        0                   Data made to daily average
        See also:           http://eklima.no/wsKlima/complete/cTimeserie_en.html

    Output options:
        'list':         returns a list of WeatherElement objects.
        'json':         returns NULL but saves a .json file til the working folder.

    URL for getting stationdata from Hakkloa 6.24.4.17.1

        http://h-web01.nve.no/chartserver/ShowData.aspx
        ?req=getchart
        &ver=1.0
        &vfmt=json
        &time=20141204T0000;20141212T0000
        &chd=ds=htsry,id=hydx[6;24;4;17;1].6000

    """

    url = "{0}&time={1};{2}&chd=ds=htsry,id=hydx[{3};{4}].6000"\
        .format(baseURL,
                fromDate.strftime('%Y%m%dT%H%M'),
                toDate.strftime('%Y%m%dT%H%M'),
                stationID.replace('.',';'),
                elementID.replace('.',';'))

    if output == 'list':

        weatherElementList = make_weather_element_list_from_url(url, stationID, elementID, {'MethodName': 'Chartserver - getYrdata'})

        # If to much data is requested, break it down to smaller portions.
        if weatherElementList == "Request less data.":
            time_delta = toDate - fromDate
            date_in_middle = (fromDate + time_delta/2).replace(hour=0, minute=0)
            weatherElementList = getYrdata(stationID, elementID, fromDate, date_in_middle, timeseries_type=timeseries_type, output=output) \
                                 + getYrdata(stationID, elementID, date_in_middle, toDate, timeseries_type=timeseries_type, output=output)
            return weatherElementList

        else:

            if timeseries_type == -1:              # do nothing
                weatherElementList = weatherElementList
            elif timeseries_type == 0:                # make dailyavaregs of hourly values
                weatherElementList = make_daily_average(weatherElementList)
            else:
                print('no valid timeseries type selected')
                weatherElementList = 'no valid timeseries type selected'
            return weatherElementList

    elif output == 'json':
        datareq = requests.get(url)
        filename = '{0}.{1}_{2}_{3}.json'\
            .format(stationID, elementID, datetime.date.today().strftime('%Y%m%d'), toDate.strftime('%Y%m%d'))
        f = open(filename, 'w')
        f.write((datareq.text).encode('utf-8'))
        f.close()
        return

    else:
        print('No valid output requested.')
        return 'No valid output requested'
def getGriddata(UTM33X,
                UTM33Y,
                elementID,
                fromDate,
                toDate,
                timeseries_type=0,
                output='list'):
    """Method gets data from the chartserver api at NVE. Method called is ShowData.aspx.
    Future dates as well as past dates are returned. Future dates are generated from model grids from met.no

    Note that griddata is based on met data from 00 to 06 dayly values. Eg. precipitation on 17th of mai is found in
    data for 06:00 18th of mai.

    Method returns [fromDate,toDate>

    :param UTM33X:          {int} X coordinate in utm33N
    :param UTM33Y:          {int} Y coordinate in utm33N
    :param elementID:       {string} Element ID in seNorge. Ex: elementID = 'fsw' is 24hr new snow depth in [cm]
    :param fromDate:        {datetime} method returns data [fromDate, toDate>
    :param toDate:          {datetime} method returns data [fromDate, toDate>
    :param timeseries_type  {int} Works only on output='list' daily = 0, no change = None (default)
    :param output:          {string} How to present the output.
    :return:                {list} List of WeatherElement objects with 24h resolution.

    Timeseries types:
        None                Data returned as received from service
        0                   Data made to daily average
        See also:           http://eklima.no/wsKlima/complete/cTimeserie_en.html

    Output options:
        'list':             returns a list of WeatherElement objects.
        'json':             returns NULL but saves a .json file til the working folder.


    ElementID's used:
        fws:                new snow last 24hrs
        sd:                 snow depth
        tm:                 temperature avarage 24hrs


    Example URL for getting grid data
        http://h-web01.nve.no/chartserver/ShowData.aspx?req=getchart
        &ver=1.0
        &vfmt=json
        &time=20141204T0000;20141212T0000
        &chd=ds=hgts,da=29,id=260151;6671132;fsw

    """

    url = '{0}&time={1};{2}&chd=ds=hgts,da=29,id={3};{4};{5}'.format(
        baseURL, fromDate.strftime('%Y%m%dT%H%M'),
        toDate.strftime('%Y%m%dT%H%M'), UTM33X, UTM33Y, elementID)

    if output == 'list':

        weatherElementList = make_weather_element_list_from_url(
            url, 'UTM33 X{0} Y{1}'.format(UTM33X, UTM33Y), elementID,
            {'MethodName': 'Chartserver - getGriddata'})

        # If to much data is requested, break it down to smaller portions.
        if weatherElementList == "Request less data.":
            time_delta = toDate - fromDate
            date_in_middle = (fromDate + time_delta / 2).replace(hour=0,
                                                                 minute=0)
            weatherElementList = \
                getGriddata(UTM33X, UTM33Y, elementID, fromDate, date_in_middle, timeseries_type=timeseries_type, output=output) \
                + getGriddata(UTM33X, UTM33Y, elementID, date_in_middle, toDate, timeseries_type=timeseries_type, output=output)
            return weatherElementList

        else:

            if elementID == 'fsw' or elementID == 'sd':
                weatherElementList = meter_from_centimeter(
                    weatherElementList)  # convert for [cm] til [m]

            if timeseries_type == -1:  # do nothing
                weatherElementList = weatherElementList
            elif timeseries_type == 0:  # make dailyavaregs of hourly values
                weatherElementList = make_daily_average(weatherElementList)
            else:
                print('no valid timeseries type selected')
                weatherElementList = 'no valid timeseries type selected'
            return weatherElementList

    elif output == 'json':
        datareq = requests.get(url)
        filename = 'X{0}_Y{1}_{2}.{3}_{4}.json'.format(
            UTM33X, UTM33Y, elementID, fromDate.strftime('%Y%m%d'),
            toDate.strftime('%Y%m%d'))
        f = open(filename, 'w')
        f.write((datareq.text).encode('utf-8'))
        f.close()
        return

    else:
        print('No valid output requested.')
        return 'No valid output requested'
def getStationdata(stationID,
                   elementID,
                   fromDate,
                   toDate,
                   timeseries_type=0,
                   output='list'):
    """Method gets data from the chartserver api at NVE. Method called is ShowData.aspx.
    The data returned from the api are 30min values but they may be recalculated to daily average in this method
    if timeseries_type=0. Method returns [fromDate,toDate>. Future dates are truncated in this method,
    but dataset may be complemented with the getYrdata in this class.

    :param stationID:   {string} Station ID in hydra. Ex: stationID  = '6.24.4'
    :param elementID:   {string} Element ID in hydra. Ex: elementID = '17.1'
    :param fromDate:    {datetime} method returns [fromDate ,toDate>
    :param toDate:      {datetime} method returns [fromDate ,toDate>
    :param output:      {string} How to present the output.
    :return:            {list} List of WeatherElement objects.


    Timeseries types:
        None                Data returned as received from service
        0                   Data made to daily average
        See also:           http://eklima.no/wsKlima/complete/cTimeserie_en.html

    Output options:
        'list':         returns a list of WeatherElement objects.
        'json':         returns NULL but saves a .json file til the working folder.

    URL for getting stationdata from Hakkloa 6.24.4.17.1

        http://h-web01.nve.no/chartserver/ShowData.aspx
        ?req=getchart
        &ver=1.0
        &vfmt=json
        &time=20141204T0000;20141212T0000
        &chd=ds=htsr,da=29,id=6.24.4.17.1

    """

    url = "{0}&time={1};{2}&chd=ds=htsr,da=29,id={3}.{4}"\
        .format(baseURL, fromDate.strftime('%Y%m%dT%H%M'), toDate.strftime('%Y%m%dT%H%M'), stationID, elementID)

    if output == 'list':
        weatherElementList = make_weather_element_list_from_url(
            url, stationID, elementID,
            {'MethodName': 'Chartserver - getStationdata'})

        # If to much data is requested, break it down to smaller portions.
        if weatherElementList == "Request less data.":
            time_delta = toDate - fromDate
            date_in_middle = (fromDate + time_delta / 2).replace(hour=0,
                                                                 minute=0)
            weatherElementList = getStationdata(stationID, elementID, fromDate, date_in_middle, timeseries_type=timeseries_type, output=output) \
                                 + getStationdata(stationID, elementID, date_in_middle, toDate, timeseries_type=timeseries_type, output=output)
            return weatherElementList

        else:
            if timeseries_type == -1:  # do nothing
                weatherElementList = weatherElementList
            elif timeseries_type == 0:  # make daily averages of hourly values
                weatherElementList = make_daily_average(weatherElementList)
            else:
                print('no valid timeseries type selected')
                weatherElementList = 'no valid timeseries type selected'
            return weatherElementList

    elif output == 'json':
        datareq = requests.get(url)
        filename = '{0}.{1}_{2}_{3}.json'\
            .format(stationID, elementID, fromDate.strftime('%Y%m%d'), datetime.date.today().strftime('%Y%m%d'))
        f = open(filename, 'w')
        f.write((datareq.text).encode('utf-8'))
        f.close()
        return

    else:
        print('No valid output requested.')
        return 'No valid output requested'
def getYrdata(stationID,
              elementID,
              fromDate,
              toDate,
              timeseries_type=0,
              output='list'):
    """
    Gets data form yr.no though the chartserver api at NVE. Method called is ShowData.aspx.
    Does not return historical values. Seems only to return +48 hrs even though more is requested.

    :param stationID:   {string} Station ID in hydra. Ex: stationID  = '6.24.4'
    :param elementID:   {string} Element ID in hydra. Ex: elementID = '17.1'
    :param fromDate:    {datetime} method returns data including fromDate
    :param toDate:      {datetime} method returns data including toDate
    :param output:      {string} How to present the output.
    :return:            List of WeatherElement objects with 24h resolution.


    Timeseries types:
        None                Data returned as received from service
        0                   Data made to daily average
        See also:           http://eklima.no/wsKlima/complete/cTimeserie_en.html

    Output options:
        'list':         returns a list of WeatherElement objects.
        'json':         returns NULL but saves a .json file til the working folder.

    URL for getting stationdata from Hakkloa 6.24.4.17.1

        http://h-web01.nve.no/chartserver/ShowData.aspx
        ?req=getchart
        &ver=1.0
        &vfmt=json
        &time=20141204T0000;20141212T0000
        &chd=ds=htsry,id=hydx[6;24;4;17;1].6000

    """

    url = "{0}&time={1};{2}&chd=ds=htsry,id=hydx[{3};{4}].6000"\
        .format(baseURL,
                fromDate.strftime('%Y%m%dT%H%M'),
                toDate.strftime('%Y%m%dT%H%M'),
                stationID.replace('.',';'),
                elementID.replace('.',';'))

    if output == 'list':

        weatherElementList = make_weather_element_list_from_url(
            url, stationID, elementID,
            {'MethodName': 'Chartserver - getYrdata'})

        # If to much data is requested, break it down to smaller portions.
        if weatherElementList == "Request less data.":
            time_delta = toDate - fromDate
            date_in_middle = (fromDate + time_delta / 2).replace(hour=0,
                                                                 minute=0)
            weatherElementList = getYrdata(stationID, elementID, fromDate, date_in_middle, timeseries_type=timeseries_type, output=output) \
                                 + getYrdata(stationID, elementID, date_in_middle, toDate, timeseries_type=timeseries_type, output=output)
            return weatherElementList

        else:

            if timeseries_type == -1:  # do nothing
                weatherElementList = weatherElementList
            elif timeseries_type == 0:  # make dailyavaregs of hourly values
                weatherElementList = make_daily_average(weatherElementList)
            else:
                print('no valid timeseries type selected')
                weatherElementList = 'no valid timeseries type selected'
            return weatherElementList

    elif output == 'json':
        datareq = requests.get(url)
        filename = '{0}.{1}_{2}_{3}.json'\
            .format(stationID, elementID, datetime.date.today().strftime('%Y%m%d'), toDate.strftime('%Y%m%d'))
        f = open(filename, 'w')
        f.write((datareq.text).encode('utf-8'))
        f.close()
        return

    else:
        print('No valid output requested.')
        return 'No valid output requested'