-
Notifications
You must be signed in to change notification settings - Fork 50
Adding Height Transformation code #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b5b3849
Add files via upload
JackMcCubbineGA 5d0aeec
Add files via upload
JackMcCubbineGA ca52ad3
Delete heights.py
JackMcCubbineGA d910c11
Add files via upload
JackMcCubbineGA 89d205d
Delete test_heights.py
JackMcCubbineGA 11070bf
Add files via upload
JackMcCubbineGA 21b9de4
Delete heights_s3.py
JackMcCubbineGA 3d63e93
Add files via upload
JackMcCubbineGA 190df2f
Delete test_heights_s3.py
JackMcCubbineGA a1906e7
Add files via upload
JackMcCubbineGA 1b1d748
Update geodepy/tests/test_heights_s3.py
JackMcCubbineGA a8c7186
Update heights_s3.py
JackMcCubbineGA 1924737
Update heights_s3.py
JackMcCubbineGA ef09ae2
Add gdal and scipy dependencies
JackMcCubbineGA caa0c23
Update test_heights_s3.py
JackMcCubbineGA 4b41c91
Update heights_s3.py
JackMcCubbineGA 3c9a2f4
Update setup.py
JackMcCubbineGA File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # -*- coding: utf-8 -*- | ||
| """ | ||
| Created on Fri Nov 29 08:56:15 2019 | ||
|
|
||
| @author: u84157 | ||
| """ | ||
| file_DOV_PV='/vsicurl/https://geoid.s3-ap-southeast-2.amazonaws.com/AVWS/DOV_PV.tif' | ||
| file_DOV_PM='/vsicurl/https://geoid.s3-ap-southeast-2.amazonaws.com/AVWS/DOV_PM.tif' | ||
| file_AG2020='/vsicurl/https://geoid.s3-ap-southeast-2.amazonaws.com/AVWS/AUSGeoid2020_RELEASEV20170908.tif' | ||
| file_AG2020_STD='/vsicurl/https://geoid.s3-ap-southeast-2.amazonaws.com/AVWS/AUSGeoid2020_RELEASEV20170908_err.tif' | ||
| file_AVWS='/vsicurl/https://geoid.s3-ap-southeast-2.amazonaws.com/AVWS/AVWS_20191107.tif' | ||
| file_AVWS_STD='/vsicurl/https://geoid.s3-ap-southeast-2.amazonaws.com/AVWS/AVWS_STD_20191107.tif' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| #___________________________________________________________________________# | ||
| # Some notes: | ||
| # Written by Jack McCubbine of Geoscience Australia, date: 08/11/2019 | ||
| # This code contains functions to handle tranformations between GPS and | ||
| # AWVS/AHD and Vice Versa | ||
| # Gridded data used for the varisous reference surfaces are geotiff files | ||
| # These allow direct access remotely using "gdal" | ||
| #___________________________________________________________________________# | ||
| # Import dependencies | ||
| import gdal | ||
| import numpy as np | ||
| from scipy.interpolate import griddata | ||
| import geodepy.Height_filenames as Height_filenames | ||
| #___________________________________________________________________________# | ||
| # Interpolation functions | ||
| def interp_file(Lat,Long,file): | ||
| # Import the DOVPM file | ||
| f = gdal.Open(file) | ||
| # load band (akin to a variable in dataset) | ||
| band = f.GetRasterBand(1) | ||
| # get the pixel width, height, etc. | ||
| transform = f.GetGeoTransform() | ||
| # Grid resolution (known) | ||
| res=transform[1] | ||
| # convert lat,lon to row,col | ||
| column = (Long - transform[0]) / transform[1] | ||
| row = (Lat - transform[3]) / transform[5] | ||
| # get pixel values surrounding data point | ||
| Surrounding_data=(band.ReadAsArray(np.floor(column-2), np.floor(row-2), 5, 5)) | ||
| # convert row,col back to north,east | ||
| Long_c = transform[0] + np.floor(column) * res | ||
| Lat_c = transform[3] - np.floor(row) * res | ||
| # set up matrices for interpolation | ||
| count=-1 | ||
| pos=np.zeros((25,2)) | ||
| Surrounding_data_v=np.zeros((25,1)) | ||
| for k in range(-2,3): | ||
| for j in range(-2,3): | ||
| count=count+1 | ||
| pos[count]=(Long_c+j*res,Lat_c-k*res) | ||
| Surrounding_data_v[count]=Surrounding_data[k+2,j+2] | ||
| interp_val=griddata(pos,Surrounding_data_v,(Long,Lat),method='cubic') | ||
| return interp_val | ||
|
|
||
| #___________________________________________________________________________# | ||
| # Functions to handle the conversions from one height to another | ||
| def GPS_to_AVWS(Lat,Long,GPS_H): | ||
| zeta=interp_file(Lat,Long,Height_filenames.file_AVWS) # AVWS file | ||
| zeta_std=interp_file(Lat,Long,Height_filenames.file_AVWS_STD) # AVWS STD file | ||
| NORMAL_H=GPS_H-zeta | ||
| return [NORMAL_H,zeta_std] | ||
|
|
||
| def AVWS_to_GPS(Lat,Long,AVWS_H): | ||
| zeta=interp_file(Lat,Long,Height_filenames.file_AVWS) # AVWS file | ||
| zeta_std=interp_file(Lat,Long,Height_filenames.file_AVWS_STD) # AVWS STD file | ||
| GPS_H=AVWS_H+zeta | ||
| return [GPS_H,zeta_std] | ||
|
|
||
| def AHD_to_AVWS(Lat,Long,AHD_H,file_AG2020): | ||
| # Convert to GPS | ||
| GPS_H=AHD_H+interp_file(Lat,Long,Height_filenames.file_AG2020) # AUSGEOID2020 file | ||
| # Convert to AVWS | ||
| Normal_H=GPS_H-interp_file(Lat,Long,Height_filenames.file_AVWS) # AVWS file | ||
| return [Normal_H] | ||
|
|
||
| def GPS_to_AHD(Lat,Long,GPS_H): | ||
| N=interp_file(Lat,Long,Height_filenames.file_AG2020) # AUSGEOID2020 file | ||
| N_std=interp_file(Lat,Long,Height_filenames.file_AG2020_STD) # AUSGEOID2020 STD file | ||
| AHD_H=GPS_H-N | ||
| return [AHD_H,N_std] | ||
|
|
||
| def AHD_to_GPS(Lat,Long,AHD_H): | ||
| N=interp_file(Lat,Long,Height_filenames.file_AG2020) # AUSGEOID2020 file | ||
| N_std=interp_file(Lat,Long,Height_filenames.file_AG2020_STD) # AUSGEOID2020 STD file | ||
| GPS_H=AHD_H+N | ||
| return [GPS_H,N_std] | ||
|
|
||
| def AVWS_to_AHD(Lat,Long,Normal_H): | ||
| # Convert to GPS | ||
| GPS_H=Normal_H+interp_file(Lat,Long,Height_filenames.file_AVWS) # AVWS file | ||
| # Convert to AHD | ||
| AHD_H=GPS_H-interp_file(Lat,Long,Height_filenames.file_AG2020) # AUSGEOID2020 file | ||
| return [AHD_H] | ||
|
|
||
| def DOV(Lat,Long): | ||
| # Convert to GPS | ||
| DOV_PM=interp_file(Lat,Long,Height_filenames.file_DOV_PM) # AVWS file | ||
| # Convert to AHD | ||
| DOV_PV=interp_file(Lat,Long,Height_filenames.file_DOV_PV) # AUSGEOID2020 file | ||
| return [DOV_PM,DOV_PV] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # -*- coding: utf-8 -*- | ||
| """ | ||
| Created on Fri Nov 08 10:52:07 2019 | ||
|
|
||
| @author: u84157 | ||
| """ | ||
| import unittest | ||
| import numpy as np | ||
| import geodepy.heights_s3 | ||
|
|
||
| #___________________________________________________________________________# | ||
| ## Some test Cases to run, check againts ga.gov.au/ausgeoid | ||
| # Test Coordinates | ||
| Long=148.716 | ||
| Lat=-25.716 | ||
| Height=0 | ||
| # What the output should be | ||
| AVWS_H=-40.79437480 | ||
| AVWS_H_STD=0.05786271 | ||
| AHD_H=-42.231267 | ||
| AHD_H_STD=0.10002191 | ||
| DOVPM=-13.71323159 | ||
| DOVPV=-2.4971921 | ||
|
|
||
| class TestHeights(unittest.TestCase): | ||
| def test_AVWS_H(self): | ||
| self.assertAlmostEqual(np.asscalar(geodepy.heights_s3.GPS_to_AVWS(Lat,Long,Height)[0]),AVWS_H,7) | ||
| def test_AVWS_H_STD(self): | ||
| self.assertAlmostEqual(np.asscalar(geodepy.heights_s3.GPS_to_AVWS(Lat,Long,Height)[1]),AVWS_H_STD,7) | ||
| def test_DOVPV(self): | ||
| self.assertAlmostEqual(np.asscalar(geodepy.heights_s3.DOV(Lat,Long)[1]),DOVPV,7) | ||
| def test_DOVPM(self): | ||
| self.assertAlmostEqual(np.asscalar(geodepy.heights_s3.DOV(Lat,Long)[0]),DOVPM,7) | ||
| def test_AHD_H(self): | ||
| self.assertAlmostEqual(np.asscalar(geodepy.heights_s3.GPS_to_AHD(Lat,Long,Height)[0]),AHD_H,7) | ||
| def test_AHD_H_STD(self): | ||
| self.assertAlmostEqual(np.asscalar(geodepy.heights_s3.GPS_to_AHD(Lat,Long,Height)[1]),AHD_H_STD,7) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.