Skip to content

4_other_tools

Yu Morishita edited this page Feb 26, 2021 · 14 revisions

4. Other Tools

For more details of the commands, use -h option to see the usage.

LiCSBAS_flt2geotiff.py

LiCSBAS_flt2geotiff.py -i infile -p dempar [-o outfile] [--zero2nan] [--nan2zero] [--a_nodata num] [--bigendian]

 -i  Path to input file (float, little endian)
 -p  Path to dem parameter file (EQA.dem_par)
 -o  Output geotiff file (Default: infile[.geo].tif)
 --a_nodata   Assign a specified nodata value in output (Default: nan)
              "None" assigns no value as nodata
 --zero2nan   Replace 0 with nan (Default: NOT replace 0 with nan)
 --nan2zero   Replace nan with 0 (Default: NOT replace nan with 0)
 --bigendian  If input file is in big endian

This script makes a GeoTIFF file from an image file (only in float32 format). The GeoTIFF file can be read by a GIS software (e.g., QGIS) and used to make a figure. Nan will be regarded as NoDataValue as default. 0 can be replaced with nan.

The GeoTIFF file can be further converted to various formats, e.g., GMT-compatible NetCDF by

gdal_translate -of NetCDF data.tiff data.grd and ASCII Gridded XYZ by gdal_translate -of XYZ data.tiff data.xyz or gdal2xyz.py data.tiff data.xyz. For more formats, please see Raster drivers of GDAL.

LiCSBAS_cum2flt.py

LiCSBAS_cum2flt.py -d yyyymmdd [-i infile] [-o outfile] [-m yyyymmdd] [-r x1:x2/y1:y2]
     [--ref_geo lon1/lon2/lat1/lat2] [--mask maskfile] [--png] 

 -d  Date to be output
 -i  Path to input cum file (Default: cum_filt.h5)
 -o  Output float32 file (Default: yyyymmdd_yyyymmdd.cum)
 -m  Master (reference) date (Default: first date)
 -r  Reference area (Default: same as info/*ref.txt)
     Note: x1/y1 range 0 to width-1, while x2/y2 range 1 to width
     0 for x2/y2 means all. (i.e., 0:0/0:0 means whole area).
 --ref_geo  Reference area in geographical coordinates.
 --mask  Path to mask file for ref phase calculation (Default: No mask)
 --png   Make png file (Default: Not make png)

This script outputs a float32 file of cumulative displacement from cum*.h5.

LiCSBAS_cum2vel.py

LiCSBAS_cum2vel.py [-s yyyymmdd] [-e yyyymmdd] [-i infile] [-o outfile] [-r x1:x2/y1:y2]
    [--ref_geo lon1/lon2/lat1/lat2] [--vstd] [--sin] [--mask maskfile] [--png] 

 -s  Start date of period to calculate velocity (Default: first date)
 -e  End date of period to calculate velocity (Default: last date)
 -i  Path to input cum file (Default: cum_filt.h5)
 -o  Output vel file (Default: yyyymmdd_yyyymmdd.vel[.mskd])
 -r  Reference area (Default: same as info/*ref.txt)
     Note: x1/y1 range 0 to width-1, while x2/y2 range 1 to width
     0 for x2/y2 means all. (i.e., 0:0/0:0 means whole area).
 --ref_geo  Reference area in geographical coordinates.
 --vstd  Calculate vstd (Default: No)
 --sin   Add sin (annual) funcsion to linear model (Default: No)
         *.amp and *.dt (time difference wrt Jan 1) are output
 --mask  Path to mask file for ref phase calculation (Default: No mask)
 --png   Make png file (Default: Not make png)

This script calculates velocity and its standard deviation from cum*.h5 and outputs them as a float32 file. Amplitude and time offset of the annual displacement can also be calculated by --sin option.

LiCSBAS_color_geotiff.py

LiCSBAS_color_geotiff.py -i infile [-c cmap] [-o outfile]
  [--cmin float] [--cmax float] [--n_color int] [--no_colorbar]

 -i  Input data GeoTIFF file
 -c  Colormap name (Default: SCM.roma_r, reverse of SCM.roma)
     Available colormaps (all cmap can be reversed with "_r"):
     - Matplotlib predefined name (e.g. viridis)
       https://matplotlib.org/tutorials/colors/colormaps.html
     - Scientific colour maps (e.g. SCM.roma)
       http://www.fabiocrameri.ch/colourmaps.php
     - Generic Mapping Tools (e.g. GMT.polar)
       https://docs.generic-mapping-tools.org/dev/cookbook/cpts.html
     - cmocean (e.g. cmocean.phase)
       https://matplotlib.org/cmocean/
     - colorcet (e.g. colorcet.CET_C1)
       https://colorcet.holoviz.org/
     - cm_insar (GAMMA standard rainbow color for wrapped phase)
     - cm_isce (ISCE standard rainbow color for wrapped phase)
 -o  Output colored GeoTIFF file (Default: [infile%.tif].cmap_cmin_cmax.tif)
 --cmin|cmax  Min|max values of color (Default: None (auto))
 --n_color    Number of rgb quantization levels (Default: 256)
 --no_colorbar   Do not create colorbar image (name: cmap_cmin_cmax.pdf)

This script creates a colored GeoTIFF from a data GeoTIFF.

LiCSBAS_contour.py

LiCSBAS_contour.py -i geotiff -c cont_int [-q cut_nodes] [-o contfile]
 [-a attrib] [-s smoothing_length] [--nodata float] [--no_zero]
 [--color_n colorcode] [--color_p colorcode] [--color_0 colorcode]
 [--width float] [--opacity float]

 -i  Input GeoTIFF file
 -c  Contour interval
 -q  Do not draw contours with less nodes than this number (Default: 10)
 -o  Output contour GeoJSON file (Default: [geotiff%.tif].cont.geojson)
 -a  Name for the attribute (good to include unit)
     (Default: geotiff file name)
 -s  Smoothing length in km (Default: 0; no smoothing)
     Note that the shapely module must be installed to use this option.
 --nodata  Nodata value (Default: nan)
 --no_zero  Do not draw contours with 0
 --color_0  Color code of contours with 0 values (Default: #000000 (black))
 --color_n  Color code of contours with negative values.
            (Default: #0000ff (blue))
 --color_p  Color code of contours with positive values.
            (Default: #ff0000 (red))
 --width  Width of contour lines (Default: 2)
 --opacity Opacity of contour lines (Default: 0.5)

Note:
 - color_[n|p|0], width and opacity have an effect in GSI Maps, not in QGIS.
 - Rocommend reducing n_node to < 10000 by -q and -s options for GSIMaps.

This script draws contours from a GeoTIFF file and output a GeoJSON file (with GSI Maps style).

LiCSBAS_cum2tstxt.py

LiCSBAS_cum2tstxt.py [-p x/y] [-g lon/lat] [-i cumfile] [-o tsfile] [-r x1:x2/y1:y2]
    [--ref_geo lon1/lon2/lat1/lat2] [--mask maskfile]

 -p  x/y coordinate of a point to be output (index range 0 to width-1)
 -g  Lon/Lat of a point to be output
 -i  Input cum*.h5 file (Default: cum_filt.h5)
 -o  Output txt file of time series (Default: ts_[x]_[y].txt)
 -r  Reference area (Default: same as info/*ref.txt)
     Note: x1/y1 range 0 to width-1, while x2/y2 range 1 to width
     0 for x2/y2 means all. (i.e., 0:0/0:0 means whole area).
 --ref_geo  Reference area in geographical coordinates.
 --mask  Path to mask file for ref calculation (Default: No mask)

 Note: either -p or -g must be specified.

This script outputs a txt file of time series of displacement at a specified point from cum*.h5.

LiCSBAS_get_value_geo.py

LiCSBAS_get_value_geo.py -i infile -p dempar -l locfile [-o outfile] [--win_size int] [--bigendian]

 -i  Input file (float, little endian, geocoded)
 -p  Dem parameter file (EQA.dem_par)
 -l  Text file of lists of point locations (lat lon)
 -o  Output text file (Default: [locfile]v.txt)
     Format: lat lon x y value value_avg (x/y start from 0)
 --win_size   Window size of boxcar averaging, must be odd integer (Default: 3)
 --bigendian  If input file is in big endian

This script gets values (and x/y coordinates) from a float32 file at specified points in geographical coordinates. Average values in a boxcar window are also output.

LiCSBAS_mask_flt.py

LiCSBAS_mask_flt.py -i infile -m maskfile [-o outfile]

 -i  Path to input float file
 -m  Path to maskfile
 -o  Output masked float file (Default: infile.mskd)

This script masks a float32 file using a mask file.

LiCSBAS_decomposeLOS.py

LiCSBAS_decomposeLOS.py -f files.txt [-o outfile] [-r resampleAlg] [--out_stats]

 -f  Text file containing input GeoTIFF file paths of LOS displacement 
     (or velocity), E component, and N component
     Format:
         dispfile1 Efile1 Nfile1
         dispfile2 Efile2 Nfile2
         ...
 -o  Prefix of output decomposed file (Default: no prefix, [EW|UD].geo.tif)
 -r  Resampling algorithm (Default: bilinear)
     (see https://gdal.org/programs/gdalwarp.html#cmdoption-gdalwarp-r)
 --out_stats  Output statistics (e.g. residuals, n_data)

This script decomposes 2 (or more) LOS displacement data to EW and UD components assuming no NS displacement (neglecting NS, e.g., Wright et al., 2004, Motagh et al., 2017). Positive values in the decomposed data mean eastward and upward displacement. The multiple LOS input data can have different coverage and resolution as they are resampled to the common area and resolution during the processing.