def _make_racmo_wind_speed() -> Layer: return Layer( id='racmo_wind_speed', title='Annual mean wind speed 1958-2019 (5km)', description= ("""Averaged annual mean wind speed in meters per second from RACMO2.3p2 for the period 1958-2019."""), tags=[], style='racmo_wind_speed', input=LayerInput( dataset=dataset, asset=dataset.assets['only'], ), steps=[ decompress_step( input_file='{input_dir}/RACMO_QGreenland_Jan2021.zip', decompress_contents_mask='magnitudes.nc', ), *warp_and_cut( input_file='{input_dir}/magnitudes.nc', output_file='{output_dir}/racmo_wind_speed.tif', cut_file=project.boundaries['data'].filepath, ), *compress_and_add_overviews( input_file='{input_dir}/racmo_wind_speed.tif', output_file='{output_dir}/racmo_wind_speed.tif', dtype_is_float=True, ), ], )
def sea_ice_age_layer(year: int, age_type: AgeType) -> Layer: layer_info = seaice_age_layers[year][age_type] return Layer( id=f'seaice_{age_type}_age_{year}', title=f"{layer_info['date_range']} {year}", description=( f"""Age of sea ice derived from weekly averaged ice motion vectors. A value of N indicates ice aged N-1 to N years. A value of 20 represents land; 21 represents ocean cells where ice age was not calculated. Week of {age_type} extent chosen based on NSDIC's Sea Ice Index 5-day average.""" ), tags=[], style='sea_ice_age', input=LayerInput( dataset=dataset, asset=dataset.assets[str(year)], ), steps=[ CommandStep( args=[ 'gdal_translate', '-b', layer_info['band_num'], ( 'NETCDF:{input_dir}/' f'iceage_nh_12.5km_{year}0101_{year}1231_v4.1.nc:age_of_sea_ice' ), '{output_dir}/age_of_sea_ice.tif', ], ), *gdal_edit( input_file='{input_dir}/age_of_sea_ice.tif', output_file='{output_dir}/edited.tif', gdal_edit_args=[ '-a_ullr', '-4518421 4518421 4506579 -4506579', ], ), *warp_and_cut( input_file='{input_dir}/edited.tif', output_file='{output_dir}/warped_and_cut.tif', cut_file=project.boundaries['background'].filepath, reproject_args=[ '-tr', '12500', '12500', ], ), *compress_and_add_overviews( input_file='{input_dir}/warped_and_cut.tif', output_file='{output_dir}/overviews.tif', dtype_is_float=False, ), ], )
def _make_layer( *, layer_id: str, title: str, description: str, style: str, filename: str, dataset: Dataset, ) -> Layer: return Layer( id=layer_id, title=title, description=description, tags=[], style=style, input=LayerInput( dataset=dataset, asset=dataset.assets['only'], ), steps=[ decompress_step( input_file='{input_dir}/archive.zip', decompress_contents_mask=filename, ), *warp_and_cut( input_file='{input_dir}/' + filename, output_file='{output_dir}/' + filename, reproject_args=[ # Source data is 0.02x-0.02 degrees resolution. Rene noted in # his email to QGreenland on 2021-01-22 that the geoid and # gravity anomaly grids are 2km resolution. '-tr', '2000', '2000', ], cut_file=project.boundaries['data'].filepath, ), *compress_and_add_overviews( input_file='{input_dir}/' + filename, output_file='{output_dir}/' + filename, dtype_is_float=True, ), ], )
def _layer(year) -> Layer: month = conc_max_month(year) month_name = calendar.month_name[month] return Layer( id=f'seaice_maximum_concentration_{year}', title=f'{month_name} {year}', description=CONCENTRATION_DESCRIPTION, tags=[], style=CONCENTRATION_STYLE, input=LayerInput( dataset=dataset, asset=dataset.assets[f'maximum_concentration_{year}'], ), # TODO: Extract to helper steps=[ CommandStep( args=[ 'gdal_calc.py', '--calc', "'A / 10.0'", '-A', '{input_dir}/*.tif', '--outfile={output_dir}/downscaled.tif', ], ), *warp_and_cut( input_file='{input_dir}/downscaled.tif', output_file='{output_dir}/warped_and_cut.tif', cut_file=project.boundaries['background'].filepath, ), *compress_and_add_overviews( input_file='{input_dir}/warped_and_cut.tif', output_file='{output_dir}/overviews.tif', dtype_is_float=False, ), ], )
title=f'September {year}', description=CONCENTRATION_DESCRIPTION, tags=[], style=CONCENTRATION_STYLE, input=LayerInput( dataset=dataset, asset=dataset.assets[f'minimum_concentration_{year}'], ), steps=[ CommandStep(args=[ 'gdal_calc.py', '--calc', "'A / 10.0'", '-A', '{input_dir}/*.tif', '--outfile={output_dir}/downscaled.tif', ], ), *warp_and_cut( input_file='{input_dir}/downscaled.tif', output_file='{output_dir}/warped_and_cut.tif', cut_file=project.boundaries['background'].filepath, ), *compress_and_add_overviews( input_file='{input_dir}/warped_and_cut.tif', output_file='{output_dir}/overviews.tif', dtype_is_float=False, ), ], ) for year in MIN_CONCENTRATION_YEARS ]
dataset=dataset, asset=dataset.assets['only'], ), steps=[ CommandStep(args=[ 'gdal_calc.py', '--calc="A*B"', '--outfile={output_dir}/' + f'masked_{layer_id}.tif', '-A', 'NETCDF:{input_dir}/GRE_G0120_0000.nc:v', '-B', 'NETCDF:{input_dir}/GRE_G0120_0000.nc:ice', ], ), *warp_and_cut( input_file='{input_dir}/' + f'masked_{layer_id}.tif', output_file='{output_dir}/' + f'{layer_id}.tif', cut_file=project.boundaries['data'].filepath, ), *compress_and_add_overviews( input_file='{input_dir}/' + f'{layer_id}.tif', output_file='{output_dir}/' + f'{layer_id}.tif', dtype_is_float=True, ), ], ) for layer_id, params in _masked_velocity_mosaic_params.items() ] velocity_mosaic_ice_mask = Layer( id='velocity_mosaic_ice_mask', title='Ice mask (120m)', description=("""Ice mask used for ITS_LIVE velocity mosiac."""),
), steps=[ *warp_and_cut( input_file=( 'NETCDF:{input_dir}/UiO_PEX_5.0_20181127_2000_2016_10km.nc:' + params['variable']), output_file='{output_dir}/' + f'{layer_id}.tif', reproject_args=[ # Webpage for this data # (https://doi.pangaea.de/10.1594/PANGAEA.888600) notes All # files are provided in Arctic Polar Stereographic projection # (EPSG:3995 WGS 84) '-s_srs', 'EPSG:3995', '-tr', '10000', '10000', # This dataset does not contain CF-compliant fields or # geotransform array. Set # `GDAL_NETCDF_IGNORE_XY_AXIS_NAME_CHECKS` to `true` to use # the provided `x` and `y` dims as coordinate values so that # gdal can compute the transform on its own. See # https://github.com/OSGeo/gdal/issues/4075 '--config', 'GDAL_NETCDF_IGNORE_XY_AXIS_NAME_CHECKS', 'true', ], cut_file=project.boundaries['data'].filepath, ), *compress_and_add_overviews( input_file='{input_dir}/' + f'{layer_id}.tif',
'-b', DEPTHS_BANDS[depth], 'NETCDF:{input_dir}/' + f'{SEASONS_FNS[season]}:t_an', '{output_dir}/extracted.tif', ], ), *warp_and_cut( input_file='{input_dir}/extracted.tif', output_file='{output_dir}/warped_and_cut.tif', cut_file=project.boundaries['data'].filepath, reproject_args=( '-tr', '25000', '25000', # A "target extent" bounding box is required to reproject # this correctly, or we receive an error like: # ERROR 1: Attempt to create 0x1 dataset is # illegal,sizes must be larger than zero. '-te', *( project.boundaries['data'].bbox.min_x, project.boundaries['data'].bbox.min_y, project.boundaries['data'].bbox.max_x, project.boundaries['data'].bbox.max_y, ), ), ), *compress_and_add_overviews( input_file='{input_dir}/warped_and_cut.tif', output_file='{output_dir}/final.tif', dtype_is_float=True, ),
tags=[], style=params['style'], input=LayerInput( dataset=dataset, asset=dataset.assets['only'], ), steps=[ decompress_step( input_file= '{input_dir}/greenland_iv_250m_s1_20191214_20200131_v1_3.zip', decompress_contents_mask=( 'greenland_iv_250m_s1_20191214_20200131_v1_3' '/greenland_iv_250m_s1_20191214_20200131_v1_3.nc'), ), *warp_and_cut( input_file= ('NETCDF:{input_dir}/greenland_iv_250m_s1_20191214_20200131_v1_3/' 'greenland_iv_250m_s1_20191214_20200131_v1_3.nc' f":{params['variable']}"), output_file='{output_dir}/' + f'{layer_id}.tif', cut_file=project.boundaries['data'].filepath, ), *compress_and_add_overviews( input_file='{input_dir}/' + f'{layer_id}.tif', output_file='{output_dir}/' + f'{layer_id}.tif', dtype_is_float=True, ), ], ) for layer_id, params in _esa_cci_velocity_params.items() ]
geothermal_heat_flow = Layer( id='geothermal_heat_flow_map', title='Flow from multiple observations (55km)', style='geothermal_heat_flow_map', description=( """Geothermal heat flow map from machine-learning algorithm (55 km native resolution)."""), tags=[], input=LayerInput( dataset=dataset, asset=dataset.assets['55km_map'], ), steps=[ *warp_and_cut( input_file= '{input_dir}/geothermal_heat_flow_map_55km_without_NGRIP.nc', output_file='{output_dir}/geothermal_heat_flow_map_55km.tif', cut_file=project.boundaries['data'].filepath, ), *compress_and_add_overviews( input_file='{input_dir}/geothermal_heat_flow_map_55km.tif', output_file='{output_dir}/geothermal_heat_flow_map_55km.tif', dtype_is_float=True, ), ], ) geothermal_heat_flow_measurements = Layer( id='geothermal_heat_flow_measurements', title='Flow measurement locations', description= ("""Heat flow measurement database used in the creation of the 'Geothermal
show=True, input=LayerInput( dataset=background_dataset, asset=background_dataset.assets['high_res'], ), steps=[ decompress_step( input_file='{input_dir}/*.zip', ), *warp_and_cut( input_file='{input_dir}/NE2_HR_LC_SR_W.tif', output_file='{output_dir}/warped_and_cut.tif', reproject_args=[ '-tr', '500', '500', # TODO import project config and access correct boundary. '-te', '-5774572.727595 -5774572.727595 5774572.727595 5774572.727595', '-dstnodata', '0', '-wo', 'SOURCE_EXTRA=100', '-wo', 'SAMPLE_GRID=YES', ], cut_file='{assets_dir}/latitude_shape_40_degrees.geojson', ), # Because the background image is large, we use JPEG compression # (`compress_and_add_overviews` step below). To do so without JPEG # artifacts around the curved clip boundary the image (appears as black # pixels around the outside edges of the image), a mask band can be # used. This step creates the mask file that will be added as a fourth # band to the RGB background image. CommandStep( id='create_mask', args=[
("""Error estimate for Greenland bed elevation and ice thickness in meters."""), }, } layers = [ Layer( id=f'bedmachine_{key}', title=f'{params["title"]} (150m)', description=params['description'], tags=['terrain_model'], style=f'bedmachine_{key}', input=LayerInput( dataset=bedmachine.bedmachine, asset=bedmachine.bedmachine.assets['only'], ), steps=[ *warp_and_cut( input_file='NETCDF:{input_dir}/' + f'{bedmachine_fn}:{key}', output_file='{output_dir}/warped_and_cut.tif', cut_file='{assets_dir}/greenland_rectangle.geojson', ), *compress_and_add_overviews( input_file='{input_dir}/warped_and_cut.tif', output_file='{output_dir}/overviews.tif', dtype_is_float=False if key == 'errbed' else True, ), ], ) for key, params in bed_datasets.items() ]