# troposim
Simulate tropospheric noise for InSAR data

## Installation
```bash
pip install troposim
```
To make an editable installation
```bash
git clone https://github.com/scottstanie/troposim && cd troposim
pip install -e .
```
## Usage
To simulate one turbulence image, you can specify the shape:
```python
from troposim import turbulence
noise = turbulence.simulate(shape=(500, 500))
```
or add a 3rd dimension to simulate a stack of images
```python
noise = turbulence.simulate(shape=(10, 500, 500))
```
The `beta` argument is the slope of the log10(power) vs log10(frequency) graph.
The default is to use a single linear slope of $\beta = 8 / 3$:
$$
P(f) \propto \frac{1}{f^\beta}
$$
For smaller-scale turbulence, you can use a different `beta`:
```python
flatter_noise = turbulence.simulate(beta=2.2)
```
Since real InSAR data typically have a power spectrum that is not a single slope, you can **estimate the spectrum from an image** and use that to simulate new data:
```python
from troposim.turbulence import Psd
psd = Psd.from_image(noise)
new_noise = psd.simulate()
```
Here the `psd` object has attributes
- `p0`: the power at the reference frequency `freq0`
- `beta`: a numpy Polynomial which was fit to the log-log PSD
along with `psd1d`, which are the radially averaged spectrum values at the `psd.freq` frequencies. You can see these with the `.plot()` method.
```python
# assuming maptlotlib is installed
psd.plot()
# Or, to plot a side-by-side of image and 1D PSD
from troposim import plotting
plotting.plot_psd(noise, freq=freq, psd1d=psd1d)
# Or just the PSD plot, no image
plotting.plot_psd1d(psd.freq, psd.psd1d)
```
To simulate a stack of new values from the PSD of one image, you simply pass in a new `shape` argument to `.simulate`:
```python
psd.simulate(shape=(10, 400, 400))
```
Note that the default fit will use a cubic polynomial.
To request only a linear fit,
```python
psd = Psd.from_image(noise, deg=1)
```
You can also save the PSD parameters for later use:
```python
psd.save(outfile="my_psd.npz")
# Later, reload from this file
psd = Psd.load(outfile)
```
## Citation
If you find this library useful, [please consider citing our paper](https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2024JB029614):
> Staniewicz, S., & Chen, J. (2025). Automatic detection of InSAR deformation and tropospheric noise features using computer vision: A case study over West Texas. Journal of Geophysical Research: Solid Earth, 130(7), e2024JB029614.
Raw data
{
"_id": null,
"home_page": null,
"name": "troposim",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "insar, simulation, troposphere, turbulence, remote-sensing, sar, synthetic-aperture-radar",
"author": "scott",
"author_email": "scott.stanie@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/a2/73/3897637df4d81d73c8f0a5ac221303030e0beb31356102b7183a7d9dd1ab/troposim-0.2.2.tar.gz",
"platform": "any",
"description": "# troposim\n\nSimulate tropospheric noise for InSAR data\n\n\n\n## Installation\n\n```bash\npip install troposim\n```\n\nTo make an editable installation\n\n```bash\ngit clone https://github.com/scottstanie/troposim && cd troposim\npip install -e .\n```\n\n## Usage\n\nTo simulate one turbulence image, you can specify the shape:\n```python\nfrom troposim import turbulence\nnoise = turbulence.simulate(shape=(500, 500))\n```\nor add a 3rd dimension to simulate a stack of images\n\n```python\nnoise = turbulence.simulate(shape=(10, 500, 500))\n```\n\nThe `beta` argument is the slope of the log10(power) vs log10(frequency) graph.\nThe default is to use a single linear slope of $\\beta = 8 / 3$:\n\n$$\nP(f) \\propto \\frac{1}{f^\\beta}\n$$\n\nFor smaller-scale turbulence, you can use a different `beta`:\n```python\nflatter_noise = turbulence.simulate(beta=2.2)\n```\n\nSince real InSAR data typically have a power spectrum that is not a single slope, you can **estimate the spectrum from an image** and use that to simulate new data:\n```python\nfrom troposim.turbulence import Psd\npsd = Psd.from_image(noise)\nnew_noise = psd.simulate()\n```\nHere the `psd` object has attributes\n- `p0`: the power at the reference frequency `freq0`\n- `beta`: a numpy Polynomial which was fit to the log-log PSD\nalong with `psd1d`, which are the radially averaged spectrum values at the `psd.freq` frequencies. You can see these with the `.plot()` method.\n\n```python\n# assuming maptlotlib is installed\npsd.plot()\n\n# Or, to plot a side-by-side of image and 1D PSD\nfrom troposim import plotting \nplotting.plot_psd(noise, freq=freq, psd1d=psd1d)\n# Or just the PSD plot, no image\nplotting.plot_psd1d(psd.freq, psd.psd1d)\n```\n\nTo simulate a stack of new values from the PSD of one image, you simply pass in a new `shape` argument to `.simulate`:\n```python\npsd.simulate(shape=(10, 400, 400))\n```\nNote that the default fit will use a cubic polynomial. \nTo request only a linear fit,\n```python\npsd = Psd.from_image(noise, deg=1)\n```\n\nYou can also save the PSD parameters for later use:\n```python\npsd.save(outfile=\"my_psd.npz\")\n# Later, reload from this file\npsd = Psd.load(outfile)\n```\n\n\n## Citation\n\nIf you find this library useful, [please consider citing our paper](https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2024JB029614):\n\n> Staniewicz, S., & Chen, J. (2025). Automatic detection of InSAR deformation and tropospheric noise features using computer vision: A case study over West Texas. Journal of Geophysical Research: Solid Earth, 130(7), e2024JB029614. \n",
"bugtrack_url": null,
"license": "mit",
"summary": "Simulate InSAR tropospheric noise",
"version": "0.2.2",
"project_urls": null,
"split_keywords": [
"insar",
" simulation",
" troposphere",
" turbulence",
" remote-sensing",
" sar",
" synthetic-aperture-radar"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "85e3449423b6a10a7380644d0e2071002c10b4c656b1eea8f292e3339624390b",
"md5": "2e524dedada8b5c414ce87ba636ad680",
"sha256": "a06fff216adf2cbb1c00596d0f633ae714aee073301402ab946bdb7f63eded3e"
},
"downloads": -1,
"filename": "troposim-0.2.2-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "2e524dedada8b5c414ce87ba636ad680",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.9",
"size": 49395,
"upload_time": "2025-08-11T19:39:46",
"upload_time_iso_8601": "2025-08-11T19:39:46.513448Z",
"url": "https://files.pythonhosted.org/packages/85/e3/449423b6a10a7380644d0e2071002c10b4c656b1eea8f292e3339624390b/troposim-0.2.2-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "a2733897637df4d81d73c8f0a5ac221303030e0beb31356102b7183a7d9dd1ab",
"md5": "496482461a78b0b42cd5b3a3c3fc067d",
"sha256": "f0b0502a36e7c891a06a2f79533af94445ee16a0ca133a21400dcd0eec96dd29"
},
"downloads": -1,
"filename": "troposim-0.2.2.tar.gz",
"has_sig": false,
"md5_digest": "496482461a78b0b42cd5b3a3c3fc067d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 47127,
"upload_time": "2025-08-11T19:39:47",
"upload_time_iso_8601": "2025-08-11T19:39:47.818431Z",
"url": "https://files.pythonhosted.org/packages/a2/73/3897637df4d81d73c8f0a5ac221303030e0beb31356102b7183a7d9dd1ab/troposim-0.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-11 19:39:47",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "troposim"
}