Skip to content

Commit

Permalink
Merge pull request #24 from leiyangleon/other_MISC_fixes
Browse files Browse the repository at this point in the history
other MISC fixes for L8 production
  • Loading branch information
leiyangleon authored Apr 8, 2021
2 parents 9090922 + c4b7903 commit 9c57da5
Show file tree
Hide file tree
Showing 6 changed files with 224 additions and 79 deletions.
27 changes: 27 additions & 0 deletions geo_autoRIFT/geogrid/Geogrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,35 @@ def geogrid(self):
##Create and set parameters
self.setState()

##check parameters
self.checkState()

##Run
geogrid.geogrid_Py(self._geogrid)
self.get_center_latlon()

##Get parameters
self.getState()

##Clean up
self.finalize()

def get_center_latlon(self):
'''
Get center lat/lon of the image.
'''
from osgeo import gdal
self.epsg = 4326
self.determineBbox()
if gdal.__version__[0] == '2':
self.cen_lat = (self._ylim[0] + self._ylim[1]) / 2
self.cen_lon = (self._xlim[0] + self._xlim[1]) / 2
else:
self.cen_lon = (self._ylim[0] + self._ylim[1]) / 2
self.cen_lat = (self._xlim[0] + self._xlim[1]) / 2
print("Scene-center lat/lon: " + str(self.cen_lat) + " " + str(self.cen_lon))


def getProjectionSystem(self):
'''
Testing with Greenland.
Expand Down Expand Up @@ -291,6 +311,13 @@ def setState(self):
self._orbit = self.orbit.exportToC()
geogrid.setOrbit_Py(self._geogrid, self._orbit)

def checkState(self):
'''
Create C object and populate.
'''
if self.repeatTime < 0:
raise Exception('Input image 1 must be older than input image 2')

def finalize(self):
'''
Clean up all the C pointers.
Expand Down
30 changes: 27 additions & 3 deletions geo_autoRIFT/geogrid/GeogridOptical.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,30 @@ def runGeogrid(self):

###Determine extent of data needed
bbox = self.determineBbox()


##check parameters
self.checkState()

##Run
self.geogrid()

self.get_center_latlon()

def get_center_latlon(self):
'''
Get center lat/lon of the image.
'''
from osgeo import gdal
self.epsgDem = 4326
self.epsgDat = self.getProjectionSystem(self.dat1name)
self.determineBbox()
if gdal.__version__[0] == '2':
self.cen_lat = (self._ylim[0] + self._ylim[1]) / 2
self.cen_lon = (self._xlim[0] + self._xlim[1]) / 2
else:
self.cen_lon = (self._ylim[0] + self._ylim[1]) / 2
self.cen_lat = (self._xlim[0] + self._xlim[1]) / 2
print("Scene-center lat/lon: " + str(self.cen_lat) + " " + str(self.cen_lon))


def getProjectionSystem(self, filename):
'''
Expand Down Expand Up @@ -147,7 +166,12 @@ def determineBbox(self, zrange=[-200,4000]):
self._ylim = [np.min(xyzs[:,1]), np.max(xyzs[:,1])]



def checkState(self):
'''
Create C object and populate.
'''
if self.repeatTime < 0:
raise Exception('Input image 1 must be older than input image 2')



Expand Down
4 changes: 3 additions & 1 deletion testGeogridOptical.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def runGeogrid(info, info1, dem, dhdx, dhdy, vx, vy, srx, sry, csminx, csminy, c
d0 = date(np.int(info.time[0:4]),np.int(info.time[4:6]),np.int(info.time[6:8]))
d1 = date(np.int(info1.time[0:4]),np.int(info1.time[4:6]),np.int(info1.time[6:8]))
date_dt_base = d1 - d0
obj.repeatTime = np.abs(date_dt_base.total_seconds())
obj.repeatTime = date_dt_base.total_seconds()
# obj.repeatTime = (info1.time - info.time) * 24.0 * 3600.0
obj.numberOfLines = info.numberOfLines
obj.numberOfSamples = info.numberOfSamples
Expand Down Expand Up @@ -196,6 +196,8 @@ def runGeogrid(info, info1, dem, dhdx, dhdy, vx, vy, srx, sry, csminx, csminy, c
'epsg': kwargs.get('epsg'),
'XPixelSize': obj.X_res,
'YPixelSize': obj.Y_res,
'cen_lat': obj.cen_lat,
'cen_lon': obj.cen_lon,
}

return run_info
Expand Down
6 changes: 5 additions & 1 deletion testGeogrid_ISCE.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ def runGeogrid(info, info1, dem, dhdx, dhdy, vx, vy, srx, sry, csminx, csminy, c
'epsg': kwargs.get('epsg'),
'XPixelSize': obj.X_res,
'YPixelSize': obj.Y_res,
'cen_lat': obj.cen_lat,
'cen_lon': obj.cen_lon,
}

return run_info
Expand Down Expand Up @@ -292,7 +294,7 @@ def runGeogridOptical(info, info1, dem, dhdx, dhdy, vx, vy, srx, sry, csminx, cs
d0 = date(np.int(info.time[0:4]),np.int(info.time[4:6]),np.int(info.time[6:8]))
d1 = date(np.int(info1.time[0:4]),np.int(info1.time[4:6]),np.int(info1.time[6:8]))
date_dt_base = d1 - d0
obj.repeatTime = np.abs(date_dt_base.total_seconds())
obj.repeatTime = date_dt_base.total_seconds()
# obj.repeatTime = (info1.time - info.time) * 24.0 * 3600.0
obj.numberOfLines = info.numberOfLines
obj.numberOfSamples = info.numberOfSamples
Expand Down Expand Up @@ -340,6 +342,8 @@ def runGeogridOptical(info, info1, dem, dhdx, dhdy, vx, vy, srx, sry, csminx, cs
'epsg': kwargs.get('epsg'),
'XPixelSize': obj.X_res,
'YPixelSize': obj.Y_res,
'cen_lat': obj.cen_lat,
'cen_lon': obj.cen_lon,
}

return run_info
Expand Down
Loading

0 comments on commit 9c57da5

Please sign in to comment.