PS2LL_spherical Subroutine

private subroutine PS2LL_spherical(x, y, lon, lat, projection_attr)

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: x
real, intent(in) :: y
real, intent(out) :: lon
real, intent(out) :: lat
double precision, intent(in) :: projection_attr(10)

Called by

proc~~ps2ll_spherical~~CalledByGraph proc~ps2ll_spherical PS2LL_spherical proc~proj2ll PROJ2LL proc~proj2ll->proc~ps2ll_spherical proc~read_country_bounding_box_data read_country_bounding_box_data proc~read_country_bounding_box_data->proc~proj2ll proc~uemep_define_subgrid uEMEP_define_subgrid proc~uemep_define_subgrid->proc~proj2ll proc~uemep_define_subgrid_extent uEMEP_define_subgrid_extent proc~uemep_define_subgrid_extent->proc~proj2ll proc~uemep_grid_roads uEMEP_grid_roads proc~uemep_grid_roads->proc~proj2ll proc~uemep_preaggregate_shipping_asi_data uEMEP_preaggregate_shipping_asi_data proc~uemep_preaggregate_shipping_asi_data->proc~proj2ll proc~uemep_read_emep uEMEP_read_EMEP proc~uemep_read_emep->proc~proj2ll proc~uemep_read_landuse_rivm_data uEMEP_read_landuse_rivm_data proc~uemep_read_landuse_rivm_data->proc~proj2ll proc~uemep_read_meteo_nc uEMEP_read_meteo_nc proc~uemep_read_meteo_nc->proc~proj2ll proc~uemep_read_monthly_and_daily_shipping_asi_data uEMEP_read_monthly_and_daily_shipping_asi_data proc~uemep_read_monthly_and_daily_shipping_asi_data->proc~proj2ll proc~uemep_read_netcdf_landuse_latlon uEMEP_read_netcdf_landuse_latlon proc~uemep_read_netcdf_landuse_latlon->proc~proj2ll proc~uemep_read_netcdf_population_latlon uEMEP_read_netcdf_population_latlon proc~uemep_read_netcdf_population_latlon->proc~proj2ll proc~uemep_read_netcdf_shipping_latlon uEMEP_read_netcdf_shipping_latlon proc~uemep_read_netcdf_shipping_latlon->proc~proj2ll proc~uemep_read_roadlink_data_ascii uEMEP_read_roadlink_data_ascii proc~uemep_read_roadlink_data_ascii->proc~proj2ll proc~uemep_read_weekly_shipping_asi_data uEMEP_read_weekly_shipping_asi_data proc~uemep_read_weekly_shipping_asi_data->proc~proj2ll proc~uemep_region_mask_new uEMEP_region_mask_new proc~uemep_region_mask_new->proc~proj2ll proc~uemep_set_region_tile_grids uEMEP_set_region_tile_grids proc~uemep_set_region_tile_grids->proc~proj2ll proc~uemep_set_tile_grids uEMEP_set_tile_grids proc~uemep_set_tile_grids->proc~proj2ll proc~uemep_calculate_emissions_for_emep uEMEP_calculate_emissions_for_EMEP proc~uemep_calculate_emissions_for_emep->proc~uemep_grid_roads proc~uemep_calculate_emissions_for_emep->proc~uemep_read_meteo_nc proc~uemep_calculate_emissions_for_emep->proc~uemep_read_monthly_and_daily_shipping_asi_data proc~uemep_calculate_emissions_for_emep->proc~uemep_read_roadlink_data_ascii proc~uemep_calculate_emissions_for_emep->proc~uemep_read_weekly_shipping_asi_data program~uemep uEMEP program~uemep->proc~read_country_bounding_box_data program~uemep->proc~uemep_define_subgrid program~uemep->proc~uemep_define_subgrid_extent program~uemep->proc~uemep_grid_roads program~uemep->proc~uemep_preaggregate_shipping_asi_data program~uemep->proc~uemep_read_emep program~uemep->proc~uemep_read_landuse_rivm_data program~uemep->proc~uemep_read_meteo_nc program~uemep->proc~uemep_read_monthly_and_daily_shipping_asi_data program~uemep->proc~uemep_read_netcdf_landuse_latlon program~uemep->proc~uemep_read_netcdf_population_latlon program~uemep->proc~uemep_read_netcdf_shipping_latlon program~uemep->proc~uemep_read_roadlink_data_ascii program~uemep->proc~uemep_read_weekly_shipping_asi_data program~uemep->proc~uemep_region_mask_new program~uemep->proc~uemep_set_region_tile_grids program~uemep->proc~uemep_set_tile_grids program~uemep->proc~uemep_calculate_emissions_for_emep

Source Code

    subroutine PS2LL_spherical(x, y, lon, lat, projection_attr)
        ! https://mathworld.wolfram.com/StereographicProjection.html
        ! grid_mapping_name = Polar_Stereographic
        ! Map parameters:
        ! longitude_of_projection_origin
        ! latitude_of_projection_origin
        ! false_easting - This parameter is optional (default is 0)
        ! false_northing - This parameter is optional (default is 0)
        ! NOTE scale_factor_at_projection_origin =0.5(1+sin(Standard Parallel))
        double precision, intent(in) :: projection_attr(10)
        real, intent(out) :: lon, lat
        real, intent(in) :: x, y
        real :: r, rho, c
        real :: earth_radius
        real :: deg2rad, rad2deg
        real :: lat0, lat0_in, lon0, lon0_in
        real :: false_easting,false_northing
        real :: scaling
        
        lon0_in = projection_attr(1)
        lat0_in = projection_attr(2)
        false_easting = projection_attr(3)
        false_northing = projection_attr(4)
        earth_radius = projection_attr(5)
        scaling = projection_attr(6)

        deg2rad = PI/180.0
        rad2deg = 180.0/PI
        r = earth_radius

        lat0 = lat0_in*deg2rad
        lon0 = lon0_in*deg2rad

        rho = sqrt((x - false_easting)*(x - false_easting) + (y-false_northing)*(y - false_northing))
        c = 2.0*atan(rho*0.5/r/scaling)
        lat = asin(cos(c)*sin(lat0) + (y - false_northing)/rho*sin(c)*cos(lat0))
        lon = lon0 + atan((x - false_easting)*sin(c)/(rho*cos(lat0)*cos(c) - (y - false_northing)*sin(lat0)*sin(c)))
        lat = lat*rad2deg
        lon = lon*rad2deg
    end subroutine PS2LL_spherical