-
Notifications
You must be signed in to change notification settings - Fork 22
geocode SLC integration test #46
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
Changes from all commits
6b02edd
fd880ed
9f0b607
97c4461
2984d49
1abbfe4
92daa0f
0164652
ebfea34
13cb5b2
7a5655c
6442402
cd70f7c
6e3069c
8eff671
175ab31
c65ace4
17a70ff
dbf457b
7e34b3f
35cb9e8
5b4dc91
07c83e4
b30f823
18c9cb4
4ddf5f8
aa1540c
8e10100
88f0487
d438b58
dd2e841
e693f51
aeb64ac
3f72ad3
b95f45c
8953342
dd7b5e1
fa33f64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,15 @@ | ||
| python>=3.9 # sentinel1-reader requirement | ||
| numpy # sentinel1-reader requirement | ||
| lxml # sentinel1-reader requirement | ||
| gdal>=3 | ||
| #isce3 # since the conda-installed isce3 is not the most updated version, installing isce3 from stratch is recommended, to stay in sync with isce3 development. | ||
| #journal # as of Mar 2022, journal from conda does not support python3.9; since it is included during isce3 installation above, comment this out temporarily. | ||
| lxml | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, we are removing it XD There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's still here - 3 lines above |
||
| pandas | ||
| pyproj | ||
| pytest | ||
| ruamel.yaml | ||
| scipy | ||
| yamale | ||
| h5py | ||
| shapely | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I though this dependency comes from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When trying to build an environment from scratch, I recall needing to add these. I will try again and see if we can do without. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For h5py and shapely- aren't those things that we use specifically in here? It seems like we wouldn't want to rely on a chain of dependencies. e.g. if isce3 got rid of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point ☝️ Regardless it's innocuous to have these items in requirements.txt right? |
||
| requests | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,102 @@ | ||
| import multiprocessing as mp | ||
| import os | ||
| import pytest | ||
| import pathlib | ||
| import types | ||
|
|
||
| import pytest | ||
| import requests | ||
| from s1reader.s1_orbit import check_internet_connection | ||
|
|
||
| from compass.utils import iono | ||
|
|
||
|
|
||
| def download_if_needed(local_path): | ||
LiangJYu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ''' | ||
| Check if given path to file exists. Download if it from zenodo does not. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| local_path: str | ||
| Path to file | ||
| ''' | ||
| # return if file is found | ||
| if os.path.isfile(local_path): | ||
| return | ||
|
|
||
| check_internet_connection() | ||
|
|
||
| dst_dir, file_name = os.path.split(local_path) | ||
|
|
||
| # create destination directory if it does not exist | ||
| if dst_dir: | ||
| os.makedirs(dst_dir, exist_ok=True) | ||
|
|
||
| # download data | ||
| dataset_url = 'https://zenodo.org/record/7668411/files/' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wondering if we should have a file inside the repository having all hard-coded paths. In this way, we do not need to hunt them when they change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| target_url = f'{dataset_url}/{file_name}' | ||
| with open(local_path, 'wb') as f: | ||
| f.write(requests.get(target_url).content) | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def geocode_slc_params(): | ||
| ''' | ||
| Parameters to be used by geocode SLC unit test | ||
|
|
||
| Returns | ||
| ------- | ||
| test_params: SimpleNamespace | ||
| SimpleNamespace containing geocode SLC unit test parameters | ||
| ''' | ||
| test_params = types.SimpleNamespace() | ||
|
|
||
| # burst ID and date of burst | ||
| burst_id = 't064_135523_iw2' | ||
| burst_date = '20221016' | ||
|
|
||
| # get test working directory | ||
| test_path = pathlib.Path(__file__).parent.resolve() | ||
|
|
||
| # set other paths relative to working directory | ||
| test_data_path = f'{test_path}/data' | ||
|
|
||
| # paths for template and actual runconfig | ||
| gslc_template_path = f'{test_data_path}/geo_cslc_s1_template.yaml' | ||
| test_params.gslc_cfg_path = f'{test_data_path}/geo_cslc_s1.yaml' | ||
|
|
||
| # read runconfig template, replace pieces, write to runconfig | ||
| with open(gslc_template_path, 'r') as f_template, \ | ||
| open(test_params.gslc_cfg_path, 'w') as f_cfg: | ||
| cfg = f_template.read().replace('@TEST_PATH@', str(test_path)).\ | ||
| replace('@DATA_PATH@', test_data_path).\ | ||
| replace('@BURST_ID@', burst_id) | ||
| f_cfg.write(cfg) | ||
|
|
||
| # files needed for geocode SLC unit test | ||
| test_files = ['S1A_IW_SLC__1SDV_20221016T015043_20221016T015111_045461_056FC0_6681.zip', | ||
| 'orbits/S1A_OPER_AUX_POEORB_OPOD_20221105T083813_V20221015T225942_20221017T005942.EOF', | ||
| 'test_dem.tiff', 'test_burst_map.sqlite3', | ||
| '2022-10-16_0000_Rosamond-corner-reflectors.csv'] | ||
| test_files = [f'{test_data_path}/{test_file}' for test_file in test_files] | ||
|
|
||
| # parallel download of test files (if necessary) | ||
| with mp.Pool(len(test_files)) as pool: | ||
| pool.map(download_if_needed, test_files) | ||
|
|
||
| # path to file containing corner reflectors | ||
| test_params.corner_coord_csv_path = test_files[-1] | ||
|
|
||
| # path the output HDF5 | ||
| output_path = f'{test_path}/product/{burst_id}/{burst_date}' | ||
| output_file_name = f'{burst_id}_{burst_date}.h5' | ||
| test_params.output_hdf5_path = f'{output_path}/{output_file_name}' | ||
|
|
||
| # path to groups and datasets in output HDF5 | ||
| test_params.grid_group_path = '/science/SENTINEL1/CSLC/grids' | ||
| test_params.raster_path = f'{test_params.grid_group_path}/VV' | ||
|
|
||
| return test_params | ||
|
|
||
| @pytest.fixture(scope='session') | ||
| def ionex_params(download_data=True): | ||
| ''' | ||
|
|
@@ -17,9 +110,8 @@ def ionex_params(download_data=True): | |
|
|
||
| Returns | ||
| ------- | ||
| tec_file: str | ||
| Path to local or downloaded TEC file to | ||
| use in the unit test | ||
| test_params : SimpleNamespace | ||
| SimpleNamespace containing parameters needed for ionex unit test | ||
| ''' | ||
| test_params = types.SimpleNamespace() | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| runconfig: | ||
| groups: | ||
| dynamic_ancillary_file_group: | ||
| dem_file: @DATA_PATH@/test_dem.tiff | ||
| static_ancillary_file_group: | ||
| burst_database_file: @DATA_PATH@/test_burst_map.sqlite3 | ||
| input_file_group: | ||
| burst_id: | ||
| - @BURST_ID@ | ||
| orbit_file_path: | ||
| - @DATA_PATH@/orbits/S1A_OPER_AUX_POEORB_OPOD_20221105T083813_V20221015T225942_20221017T005942.EOF | ||
| safe_file_path: | ||
| - @DATA_PATH@/S1A_IW_SLC__1SDV_20221016T015043_20221016T015111_045461_056FC0_6681.zip | ||
| pge_name_group: | ||
| pge_name: CSLC_S1_PGE | ||
| primary_executable: | ||
| product_type: CSLC_S1 | ||
| processing: | ||
| rdr2geo: | ||
| enabled: false | ||
| geo2rdr: | ||
| lines_per_block: 1000 | ||
| numiter: 25 | ||
| threshold: 1.0e-08 | ||
| geocoding: | ||
| flatten: true | ||
| lines_per_block: 1000 | ||
| x_posting: 5 | ||
| x_snap: null | ||
| y_posting: 10 | ||
| y_snap: null | ||
| polarization: co-pol | ||
| range_split_spectrum: | ||
| enabled: False | ||
| product_path_group: | ||
| product_path: @TEST_PATH@/product | ||
| sas_output_file: @TEST_PATH@/product | ||
| scratch_path: @TEST_PATH@/scratch | ||
| worker: | ||
| gpu_enabled: false | ||
| gpu_id: 0 | ||
| internet_access: false | ||
| name: cslc_s1_workflow_default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these are getting created in the test directory and we want to ignore them, what if we use a temporary pytest directory that'll get removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E.g. in conftest.py, using https://docs.pytest.org/en/7.1.x/how-to/tmp_path.html#the-tmp-path-factory-fixture
But now that i've written this out, I'm thinking you may have stored it in the
tests/directory so that you could inspect the output, so feel free to ignore this suggestion if that's the caseThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your reasoning for the scratch directory is spot on.
tempfile.TemporaryDirectorycould be used just for unit tests but would disable ability to check intermediate results.