https://github.com/cjtu/iirspy
Python code to process CH2 IIRS image data in python
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.1%) to scientific vocabulary
Repository
Python code to process CH2 IIRS image data in python
Basic Info
- Host: GitHub
- Owner: cjtu
- License: mit
- Language: Python
- Default Branch: main
- Size: 5.78 MB
Statistics
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
IIRSpy
Toolkit for working with ISRO's Chandrayaan-2 IIRS dataset. This is a work in progress - comes with no guarantees, is not yet tested, and is subject to change without notice!
Installation
- Fork / clone this repository.
- Get uv package manager installation
- From the main
iirspydirectory runuv run make test- This will make a new virtual environment and run the
iirspytests - You can now use this
venvfrom an IDE oruv run ipythonfor an interactive prompt
- This will make a new virtual environment and run the
Current Workflow
- Download IIRS data from the PRADAN / ISSDC system (requires an account).
Use
iirspyto read data by giving the datetime basename and a local directory. UseL0for raw orL1for calibrated. The package unzips the downloaded files if necessary.python import iirspy extent = (5, 245, 4000, 8000) # Optional (xmin, xmax, ymin, ymax), defaults to full image iirs_l0_raw = iirspy.L0("20210720T2333026105", "/path/to/data/", extent) iirs_l1_rad = iirspy.L1("20210720T2333026105", "/path/to/data/", extent)(Optional): Check that files were downloaded and unzipped correctly (slow!). Useful when files are added or changed. Prints nothing if successful.
python iirs_l0_raw.checksum() iirs_l1_raw.checksum()Plot images. Images are handled with
xarrayand can be accessed directly withL0.imgorL1.img.```python ax = iirsl0raw.plot() # Plot band 12 by default
Plot desired band from raw and calibrated image side by side
fig, axs = plt.subplots(1, 2, figsize=(10, 4)) iirsl0raw.plot(band=79, ax=axs[0]) iirsl1rad.plot(band=79, ax=axs[1])
Plot the median spectrum of a subset of the image using xarray
iirsl0raw.img.sel(y=slice(6000, 6250)).median(dims=('x', 'y')).plot() ```
Calibration (coming soon)
python radiance = iirs_l0_raw.calibrate_to_rad() reflectance = iirs_l1_rad.calibrate_to_refl()
Other features
The IIRS classes L0 and L1 provide access to image metadata.
```python l0 = iirspy.L0("20210720T2333026105", "/path/to/data/")
Print paths to the image files in this image bundle
print("Qub path", l0.qub) print("Hdr path", l0.hdr) print("Xml path", l0.xml)
...etc for lbr, oat, oath, spm. L1 files also have csv and csv-xml
The projection, start and stop time, exposure and gain are stored in metadata
print("Metadata", l0.metadata)
Not all metadata is loaded in by default, but you can access other values in the XML file with .metaget (thanks to pdr!)
print("Solar inc (deg):", l0.metaget("isda:solar_incidence")) ```
Works in progress
Calibrate from L0 raw to L1 radiance
Note: Raw data from ISSDCC is already dark subtracted.
- (Optional): Remove bad pixels from gain and offset array
- Apply gain and offset from lookup table to convert DN to radiance [mW cm^-2 sr^-1 um^-1]
- (Optional): Destripe the result.
- (Not implemented) Postprocessing (keystone correction, radiance adjustment at order-sorting-filters and at sensor edges).
- Write to file as 32-bit floating point binary BSQ.
Georeferencing to LOLA DEM
Using the ldem_80s_20m from LOLA.
- Read image with lat/lon extent in python and find nearest latitudes given in the geom
.csvfile - Crop to desired lines using
gdal - Import into QGIS
- Select tie-points from
ldemto IIRS image - Warp DEM to image coords (bilinear interpolation, thin plate spline)
Manual method:
- Read reflectance image into QGIS
- Choose tie points (or use the previous ones for dem, reversed)
- Project to Spole stereo (
IAU_2015:30135)
Reflectance correction
- Read IIRS L1 data from
.qub - Convert radiance units to SI (x0.01) [1000 mW/cm^2/sr/um] -> [W/m^2/sr/um]
- (Optional) Find bad bands (
iirs_bad_bands.csv) for this img's exposure and gain (.xml) and set those bands to nodata - (Optional) Run the fourier destriper on the IIRS image to smooth artefacts
- (Optional) Find bad bands (
- Read solar spectrum (
ch2_iirs_solar_flux.txt) and scale by solar distance (spice) at image collection time - Get local solar incidence and azimuth for each line of the image from
.spm- (Optional) Adjust solar incidence by dem
- Resample the
ldemto the resolution of the IIRS image - Get slope from gradient of
ldem - Dot product between solar inc/az vector and surface normal vector
- Resample the
- (Optional) Adjust solar incidence by dem
- Do I/F refl correction (radiance / (cosinc * solarflux)) on all pixels
- (Optional): apply spectral polish (don't - makes the spectra worse)
- (Optional): apply spectral smoothing (usually do the 3-band boxcar)
- Write to geotif or envi img/hdr format
- (Optional): Edit envi hdr / geotiff metadata to add wavelength band labels
Owner
- Name: Christian J. Tai Udovicic
- Login: cjtu
- Kind: user
- Location: Honolulu, HI
- Website: cjtu.github.io
- Repositories: 26
- Profile: https://github.com/cjtu
Open planetary science, software dev, data science @openplanetary
GitHub Events
Total
- Push event: 9
- Pull request event: 6
- Create event: 4
Last Year
- Push event: 9
- Pull request event: 6
- Create event: 4
Dependencies
- actions/setup-python v5 composite
- astral-sh/setup-uv v2 composite
- ./.github/actions/setup-python-env * composite
- actions/cache v4 composite
- actions/checkout v4 composite
- ./.github/actions/setup-python-env * composite
- actions/checkout v4 composite
- python 3.12-slim build
- dask >=2025.2.0
- matplotlib >=3.9.4
- numpy >=2.0.2
- opencv-python >=4.11.0.86
- pandas >=2.2.3
- pdr >=1.3.0
- rioxarray >=0.15.0
- scipy >=1.13.1
- xarray >=2024.7.0
- xarray-regrid >=0.4.0
- 124 dependencies