Skip to content

Commit

Permalink
Merge pull request #81 from PolarGeospatialCenter/strip-index-rel-flds
Browse files Browse the repository at this point in the history
Strip DEM index changes
  • Loading branch information
clairecporter authored Aug 28, 2023
2 parents b1bd4fe + e4137c5 commit 22069bb
Show file tree
Hide file tree
Showing 7 changed files with 521 additions and 210 deletions.
204 changes: 112 additions & 92 deletions index_setsm.py

Large diffs are not rendered by default.

19 changes: 13 additions & 6 deletions lib/dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ def __init__(self,metapath,md=None):
setattr(self, p, None)

# Note: this approach will not work for DSP dems being used as proxies for 50cm
self.has_lsf = self.filesz_lsf > 0
self.has_nonlsf = self.filesz_dem > 0
if not hasattr(self,'has_lsf'):
self.has_lsf = self.filesz_lsf > 0
if not hasattr(self, 'has_nonlsf'):
self.has_nonlsf = self.filesz_dem > 0
self.is_xtrack = bool(self.is_xtrack)

else:
Expand Down Expand Up @@ -598,6 +600,8 @@ def __init__(self, filepath, md=None):
self.rmse = -9999
self._set_density_and_stats_attribs()
self._set_group_attribs_from_scenes()
self.is_xtrack = bool(self.is_xtrack)
self.is_lsf = bool(self.is_lsf)

else:
self.srcfp = filepath
Expand Down Expand Up @@ -671,7 +675,7 @@ def __init__(self, filepath, md=None):
self.release_version = groups[k]
break

self.is_xtrack = 1 if xtrack_sensor_pattern.match(self.sensor1) else 0
self.is_xtrack = True if xtrack_sensor_pattern.match(self.sensor1) else False
self.is_dsp = False # Todo modify when dsp strips are a thing
self.rmse = -9999 # if present, the metadata file value will overwrite this
self.min_elev_value = None
Expand Down Expand Up @@ -709,7 +713,7 @@ def get_geom_wgs84(self):
ctf = osr.CoordinateTransformation(srs, srs_wgs84)
geom.Transform(ctf)

return geom;
return geom

def get_geocell(self):
if not self.geocell:
Expand Down Expand Up @@ -1771,6 +1775,7 @@ def __init__(self, srcfp, md=None):
if match:
groups = match.groupdict()
self.tilename = groups['tile']
self.res_str = groups['res']
self.res = groups['res']
# In case release version is in the file name and not the meta.txt
self.release_version = groups['relversion'].strip('v') if groups['relversion'] else None
Expand All @@ -1794,10 +1799,10 @@ def __init__(self, srcfp, md=None):
self.regmetapath = os.path.join(self.srcdir, self.tileid + '_reg.txt')

if self.scheme:
self.supertile_id = '_'.join([self.scheme,self.tilename,self.res])
self.supertile_id = '_'.join([self.scheme,self.tilename,self.res_str])
self.supertile_id_no_res = '_'.join([self.scheme,self.tilename])
else:
self.supertile_id = '_'.join([self.tilename,self.res])
self.supertile_id = '_'.join([self.tilename,self.res_str])
self.supertile_id_no_res = self.tilename
self.tile_id_no_res = '_'.join([self.supertile_id_no_res, self.subtile]) if self.subtile else self.supertile_id_no_res
self.density = None
Expand Down Expand Up @@ -2077,6 +2082,7 @@ def _rebuild_scene_from_dict(self, md):
'proj4',
'regmetapath',
'res',
'res_str',
'srcdir',
'srcfn',
'srcfp',
Expand Down Expand Up @@ -2116,6 +2122,7 @@ def _set_component_attribs(self):
self.acqdate_min = acqdate_min
self.acqdate_max = acqdate_max


class RegInfo(object):

def __init__(self, dx, dy, dz, num_gcps, mean_resid_z, src, name=None):
Expand Down
63 changes: 48 additions & 15 deletions lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ def __init__(self, print_warnings=None):
# at the top of only the scripts in which you want to handle warnings.
setup_gdal_error_handler(catch_warnings=True, print_uncaught_warnings=True)

PROJECTS = {
'arcticdem': 'ArcticDEM',
'rema': 'REMA',
'earthdem': 'EarthDEM',
}

# Copy DEM global vars
deliv_suffixes = (
Expand Down Expand Up @@ -230,10 +235,10 @@ def __init__(self, print_warnings=None):
StandardAttribute("PAIRNAME", "", ogr.OFTString, 64, 0),
StandardAttribute("SENSOR1", "", ogr.OFTString, 8, 0),
StandardAttribute("SENSOR2", "", ogr.OFTString, 8, 0),
StandardAttribute("ACQDATE1", "", ogr.OFTString, 32, 0),
StandardAttribute("ACQDATE2", "", ogr.OFTString, 32, 0),
StandardAttribute("AVGACQTM1", "", ogr.OFTString, 32, 0),
StandardAttribute("AVGACQTM2", "", ogr.OFTString, 32, 0),
StandardAttribute("ACQDATE1", "", ogr.OFTDateTime, 32, 0),
StandardAttribute("ACQDATE2", "", ogr.OFTDateTime, 32, 0),
StandardAttribute("AVGACQTM1", "", ogr.OFTDateTime, 32, 0),
StandardAttribute("AVGACQTM2", "", ogr.OFTDateTime, 32, 0),
StandardAttribute("CATALOGID1", "", ogr.OFTString, 32, 0),
StandardAttribute("CATALOGID2", "", ogr.OFTString, 32, 0),
StandardAttribute("CENT_LAT", "", ogr.OFTReal, 0, 0),
Expand All @@ -246,15 +251,14 @@ def __init__(self, print_warnings=None):
StandardAttribute("PROJ4", "", ogr.OFTString, 100, 0),
StandardAttribute("ND_VALUE", "", ogr.OFTReal, 0, 0),
StandardAttribute("DEM_RES", "", ogr.OFTReal, 0, 0),
StandardAttribute("CR_DATE", "", ogr.OFTString, 32, 0),
# StandardAttribute("CR_DATE", "", ogr.OFTDateTime, 32, 0),
StandardAttribute("CR_DATE", "", ogr.OFTDateTime, 32, 0),
StandardAttribute("ALGM_VER", "", ogr.OFTString, 32, 0),
StandardAttribute("S2S_VER", "", ogr.OFTString, 32, 0),
StandardAttribute("IS_LSF", "", ogr.OFTInteger, 8, 8),
StandardAttribute("IS_XTRACK", "", ogr.OFTInteger, 8, 8),
StandardAttribute("EDGEMASK", "", ogr.OFTInteger, 8, 8),
StandardAttribute("WATERMASK", "", ogr.OFTInteger, 8, 8),
StandardAttribute("CLOUDMASK", "", ogr.OFTInteger, 8, 8),
StandardAttribute("IS_LSF", "", ogr.OFSTBoolean, 0, 0),
StandardAttribute("IS_XTRACK", "", ogr.OFSTBoolean, 0, 0),
StandardAttribute("EDGEMASK", "", ogr.OFSTBoolean, 0, 0),
StandardAttribute("WATERMASK", "", ogr.OFSTBoolean, 0, 0),
StandardAttribute("CLOUDMASK", "", ogr.OFSTBoolean, 0, 0),
StandardAttribute("MASK_DENS", "", ogr.OFTReal, 0, 0),
StandardAttribute("VALID_DENS", "", ogr.OFTReal, 0, 0),
StandardAttribute("VALID_AREA", "", ogr.OFTReal, 0, 0),
Expand Down Expand Up @@ -285,12 +289,41 @@ def __init__(self, print_warnings=None):
StandardAttribute("FILESZ_MT", "", ogr.OFTReal, 0, 0),
StandardAttribute("FILESZ_OR", "", ogr.OFTReal, 0, 0),
StandardAttribute("FILESZ_OR2", "", ogr.OFTReal, 0, 0),
StandardAttribute("INDEX_DATE", "", ogr.OFTString, 32, 0),
# StandardAttribute("INDEX_DATE", "", ogr.OFTDateTime, 32, 0),
StandardAttribute("INDEX_DATE", "", ogr.OFTDateTime, 32, 0),
]

DEM_ATTRIBUTE_DEFINITION_RELVER = [
StandardAttribute("REL_VER", "", ogr.OFTString, 20, 0)
DEM_ATTRIBUTE_DEFINITIONS_RELEASE = [
StandardAttribute("DEM_ID", "", ogr.OFTString, 254, 0),
StandardAttribute("PAIRNAME", "", ogr.OFTString, 64, 0),
StandardAttribute("STRIPDEMID", "", ogr.OFTString, 254, 0),
StandardAttribute("SENSOR1", "", ogr.OFTString, 8, 0),
StandardAttribute("SENSOR2", "", ogr.OFTString, 8, 0),
StandardAttribute("CATALOGID1", "", ogr.OFTString, 32, 0),
StandardAttribute("CATALOGID2", "", ogr.OFTString, 32, 0),
StandardAttribute("ACQDATE1", "", ogr.OFTDateTime, 32, 0),
StandardAttribute("ACQDATE2", "", ogr.OFTDateTime, 32, 0),
StandardAttribute("GSD", "", ogr.OFTReal, 0, 0),
StandardAttribute("EPSG", "", ogr.OFTInteger, 8, 8),
StandardAttribute("SETSM_VER", "", ogr.OFTString, 32, 0),
StandardAttribute("S2S_VER", "", ogr.OFTString, 32, 0),
StandardAttribute("CR_DATE", "CREATIONDATE", ogr.OFTDateTime, 32, 0),
StandardAttribute("GEOCELL", "", ogr.OFTString, 10, 0),
StandardAttribute("IS_LSF", "", ogr.OFSTBoolean, 0, 0),
StandardAttribute("IS_XTRACK", "", ogr.OFSTBoolean, 0, 0),
StandardAttribute("VALID_DENS", "VALID_AREA_MATCHTAG_DENSITY", ogr.OFTReal, 0, 0),
StandardAttribute("VALID_AREA", "VALID_AREA_SQKM", ogr.OFTReal, 0, 0),
StandardAttribute("VALID_PERC", "VALID_AREA_PERCENT", ogr.OFTReal, 0, 0),
StandardAttribute("WATER_AREA", "WATER_AREA_SQKM", ogr.OFTReal, 0, 0),
StandardAttribute("WATER_PERC", "WATER_AREA_PERCENT", ogr.OFTReal, 0, 0),
StandardAttribute("CLOUD_AREA", "CLOUD_AREA_SQKM", ogr.OFTReal, 0, 0),
StandardAttribute("CLOUD_PERC", "CLOUD_AREA_PERCENT", ogr.OFTReal, 0, 0),
StandardAttribute("AVGCONVANG", "AVG_CONVERGENCE_ANGLE", ogr.OFTReal, 0, 0),
StandardAttribute("AVG_HT_ACC", "AVG_EXPECTED_HEIGHT_ACCURACY", ogr.OFTReal, 0, 0),
StandardAttribute("AVG_SUNEL1", "AVG_SUN_ELEV1", ogr.OFTReal, 0, 0),
StandardAttribute("AVG_SUNEL2", "AVG_SUN_ELEV2", ogr.OFTReal, 0, 0),
StandardAttribute("RMSE", "", ogr.OFTReal, 0, 0),
StandardAttribute("FILEURL", "", ogr.OFTString, 254, 0),
StandardAttribute("S3URL", "", ogr.OFTString, 254, 0),
]

SCENE_ATTRIBUTE_DEFINITIONS_BASIC = [
Expand Down
Loading

0 comments on commit 22069bb

Please sign in to comment.