Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision f77ad6e7fd90f3c0eb255bd553d4666b5db40bcf authored by Matt Garthwaite on 04 August 2020, 00:12:52 UTC, committed by Matt Garthwaite on 04 August 2020, 00:12:52 UTC
update release date and authors
1 parent e326b29
  • Files
  • Changes
  • 68a425b
  • /
  • utils
  • /
  • create_lv_theta.py
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:f77ad6e7fd90f3c0eb255bd553d4666b5db40bcf
directory badge
swh:1:dir:f616e4c6301c398df4c41b55d3e9ab076b15284d
content badge
swh:1:cnt:d33ed0f1196b18b9216daaa899f4ab8a34be169a

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
create_lv_theta.py
# This Python module is part of the PyRate software package
#
# Copyright 2020 Geoscience Australia
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
'''
This is used to create the dummy incidence map file .inc file
This is used to create the dummy elevation map file .lv_theta file
'''

import os

import numpy as np
from osgeo import gdal

from pyrate.core import shared, ifgconstants as ifc, gamma
from tests import common

elevation_file = os.path.join(common.SML_TEST_GAMMA,
                              os.path.splitext(common.SML_TEST_DEM_GAMMA)[0]
                              + '.lv_theta')

inc_file = os.path.join(common.SML_TEST_GAMMA,
                        os.path.splitext(common.SML_TEST_DEM_GAMMA)[0]
                        + '.inc')

dest_lv_theta = os.path.splitext(elevation_file)[0] + '_lv_theta.tif'
dest_inc = os.path.splitext(elevation_file)[0] + '_inc.tif'

dem_header_file = common.SML_TEST_DEM_HDR_GAMMA

dem_header = gamma.parse_dem_header(dem_header_file)

header = gamma.parse_epoch_header(
    os.path.join(common.SML_TEST_GAMMA, '20060828_slc.par'))


incidence_angle = header[ifc.PYRATE_INCIDENCE_DEGREES]
incidence_data = np.ones(shape=(dem_header[ifc.PYRATE_NROWS],
                                dem_header[ifc.PYRATE_NCOLS])
                         ) * incidence_angle

elevation_data = np.ones(shape=(dem_header[ifc.PYRATE_NROWS],
                                dem_header[ifc.PYRATE_NCOLS])
                         ) * (90.0 - incidence_angle)

shared.write_unw_from_data_or_geotiff(geotif_or_data=incidence_data,
                                      dest_unw=inc_file,
                                      ifg_proc=1)

shared.write_unw_from_data_or_geotiff(geotif_or_data=elevation_data,
                                      dest_unw=elevation_file,
                                      ifg_proc=1)

header.update(dem_header)
header[ifc.PYRATE_TIME_SPAN] = 0
header[ifc.SECOND_DATE] = 0
header[ifc.DATA_UNITS] = 'degrees'
header[ifc.DATA_TYPE] = ifc.INCIDENCE
header[ifc.SECOND_TIME] = 0
shared.write_geotiff(header=header, data_path=elevation_file,
                     dest=dest_lv_theta, nodata=np.nan)

shared.write_geotiff(header=header, data_path=inc_file,
                     dest=dest_inc, nodata=np.nan)


ds = gdal.Open(dest_lv_theta, gdal.GA_ReadOnly)
data_elevation = ds.ReadAsArray()
ds = None


ds = gdal.Open(dest_inc, gdal.GA_ReadOnly)
data_inc = ds.ReadAsArray()
ds = None

np.testing.assert_array_almost_equal(90 - incidence_data, data_elevation,
                                     decimal=4)
np.testing.assert_array_almost_equal(incidence_data, data_inc,
                                     decimal=4)
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API