Exemplo n.º 1
0
def redirect(rec_params, resolution):
    """
        Change the parameters that are not common between the information that came from the view and the information that has to send to the rest EMEP site to get the same thing
    """
    dict_EMEP = get_Dict_EMEP()
    if 'time' in rec_params.keys():
        return rec_params['time'].split('-')[0]
    else:
        return list(dict_EMEP['datasets'][resolution].keys())[0]
Exemplo n.º 2
0
def checkLayer(layer, resolution, default_year):
    """Verify the name of the layer and its time dimension"""
    if "Dimension" in layer.keys():
        dict_EMEP = get_Dict_EMEP()
        listDates = dict_EMEP['ListDates'][resolution]
        for year in dict_EMEP['datasets'][resolution]:
            if year != default_year:
                layer['Dimension']['#text'] += ',' + createTimeDimension(
                    year, listDates)
Exemplo n.º 3
0
def Emep_GetMap(rec_params, resolution):
    """Corresponds to the WMS service: Get Map"""
    dict_EMEP = get_Dict_EMEP()
    year = redirect(rec_params, resolution)
    emep_wms_url = global_settings.EMEP_URL_BASE + dict_EMEP['services']['wms']

    url_data = dict_EMEP['datasets'][resolution][year]['EMEPSite']
    resp = request_data(emep_wms_url + url_data, rec_params,
                        headers_image_accept)
    return [resp.headers['Content-Type'], resp.content]
Exemplo n.º 4
0
def list_gases(resolution):
    """Give the basic information to query the proxy. It gives the list of gases available for a specific resolution """
    dict_EMEP = get_Dict_EMEP()
    out = {}
    out['success'] = True
    out['listGases'] = dict_EMEP['ListGases'][resolution]

    return HttpResponse(
        json.dumps(out),
        content_type='application/json',
        status=200)
Exemplo n.º 5
0
def Emep_GetFeatureInfo(rec_params, resolution):
    """Corresponds to the WMS service: Get GetFeatureInfo"""
    dict_EMEP = get_Dict_EMEP()
    emep_wms_url = global_settings.EMEP_URL_BASE + dict_EMEP['services']['wms']

    year = redirect(rec_params, resolution)
    url_data = dict_EMEP['datasets'][resolution][year]['EMEPSite']
    resp = request_data(emep_wms_url + url_data, rec_params,
                        headers_xml_accept)
    content = convertCommonFormat(resp.content)
    return ["application/json", content]
Exemplo n.º 6
0
def Emep_GetLegendGraphic(rec_params, resolution):
    """
        For a specific layer it is possible to obtain the legend of the images obtain through the WMS service
    """
    dict_EMEP = get_Dict_EMEP()
    emep_wms_url = global_settings.EMEP_URL_BASE + dict_EMEP['services']['wms']
    default_year = list(dict_EMEP['datasets'][resolution].keys())[0]
    url_data = dict_EMEP['datasets'][resolution][default_year]['EMEPSite']
    resp = request_data(emep_wms_url + url_data, rec_params,
                        headers_image_accept)
    return [resp.headers['Content-Type'], base64.b64encode(resp.content)]
Exemplo n.º 7
0
def Emep_GetCapabilities(rec_params, resolution):
    """Corresponds to the WMS service: Get Capabilities"""
    dict_EMEP = get_Dict_EMEP()
    emep_wms_url = global_settings.EMEP_URL_BASE + dict_EMEP['services']['wms']

    default_year = list(dict_EMEP['datasets'][resolution].keys())[0]
    url_data = dict_EMEP['datasets'][resolution][default_year]['EMEPSite']

    resp = request_data(emep_wms_url + url_data, rec_params,
                        headers_xml_accept)
    content = Content_Capabilities(resp.content, resolution, default_year)
    return [resp.headers['Content-Type'], content]
Exemplo n.º 8
0
def list_resolution():
    """
        List the resolutions
    """
    dict_EMEP = get_Dict_EMEP()
    if global_settings.PROXY_DEFAULT == 'GEOSERVER':
        listResolution = ['year', 'month']
    else:
        listResolution = dict_EMEP['resolutions']

    limitBounds = dict_EMEP['LimitsBounds']

    return [limitBounds, listResolution]
Exemplo n.º 9
0
def Update_styles_GeoServer():
    dict_EMEP = get_Dict_EMEP()
    gs_url, gs_rest_url, user, pwd = get_url_user_pwd_geoserver()
    for resolution in dict_EMEP['resolutions']:

        ##############################################################################################################################################
        # Não está a fazer atualizar the resolucao horária e diária !!!!!!!!!!!!!!!!!!!
        if resolution == 'hour' or resolution == 'day': # or resolution == 'month':
            continue
        
        ##################################################################################################################################################

        years = dict_EMEP['datasets'][resolution].keys()

        for year in years:
            updateStyles(resolution + '-' + year, global_settings.STYLE_NAME_GENERAL, gs_rest_url, user, pwd, global_settings.PATH_EMEP_STYLE)
Exemplo n.º 10
0
            log_task_file("DONE! Mask array is compute: %s time: %f" %
                          (mask_path, (end - start)))

            mask.dump(mask_path)
        # else:
        #     mask = np.load(mask_path, allow_pickle=True)

    return mask


if __name__ == "__main__":
    # dict_EMEP = EMEP_Create_dict("2020", "2019")
    # print(json.dumps(dict_EMEP, indent=2))

    directory = global_settings.PATH_TMP_FILES
    dict_EMEP = get_Dict_EMEP()
    filename = 'EMEP01_rv4_35_year.2018met_2018emis.nc'
    polygon_path = '/home/fmmf/Desktop/TESE/my_geonode/geonode_tmp/Poligonos_mar_buffer.shp'
    # mask = np.load(directory + '/mask.npy', allow_pickle=True)

    # UploadEMEPDatasets(dict_EMEP)

    # filename = download_FILE(dict_EMEP['services']['httpserver']+dict_EMEP['datasets']['year']['2018']['EMEPSite'], "year-2018", directory + '/old_NC')

    # print(filename)

    # uploadNetCDF("year-2018")

    # netcdf(filename, dict_EMEP, 'year', polygon_path, mask, directory)

    # create_new_depositions_rasters(filename, dict_EMEP, 'year', directory)