Metadata-Version: 2.4
Name: opensr-sr1m
Version: 0.2.0
Summary: Sentinel-2 10 m to 1 m RGB super-resolution for points and dates
Author: Eavheang
License-Expression: MIT
Project-URL: Homepage, https://github.com/Eavheang/openSR
Project-URL: Issues, https://github.com/Eavheang/openSR/issues
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: GIS
Classifier: Topic :: Scientific/Engineering :: Image Processing
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: pillow
Requires-Dist: torch
Requires-Dist: rasterio
Requires-Dist: shapely
Requires-Dist: planetary-computer
Requires-Dist: pystac-client
Requires-Dist: mlstac
Requires-Dist: sen2sr
Requires-Dist: opensr-srgan>=1.1.0
Dynamic: license-file

# opensr

Sentinel-2 L2A (Planetary Computer) 10 m to 1 m RGB super-resolution for any
set of locations and dates. The SEN2-SR model takes 10 m to 2.5 m; bicubic
resampling plus sharpening then puts it on a 1 m grid. Detail finer than
~2.5 m is not recovered, so treat 1 m as a pixel size, not true resolution.

Each (location, date) pair becomes a 5.12 km GeoTIFF (5120 x 5120 px at 1 m);
a run folder and a zip of it are written per call.

## Install

```bash
pip install opensr-sr1m
# or, from a local checkout
pip install -e .
```

## Use

```python
import opensr.inferutils

# one location, one date -> opensr_out/output_2026-11-22_Phnom_Penh/ (+ .zip)
opensr.inferutils.run((104.9160, 11.5564), "2026-11-22", location="Phnom Penh")

# many locations x many dates (every combination is processed)
# -> /content/s2dr3_out/output_2026-10-16_to_2026-11-22_Cambodia/
results = opensr.inferutils.run(
    [(105.392986, 14.121299), (104.9160, 11.5564)],
    ["2026-10-16", "2026-11-05", "2026-11-22"],
    out_dir="/content/s2dr3_out",
    location="Cambodia",
)

# CSV text or a CSV file path also work (lon first, lat second, header optional)
opensr.inferutils.run("points.csv", ["2026-11-22"])
```

Dates work like [S2DR3](https://www.gamma.earth/try-it-free/) (Gamma Earth's
Sentinel-2 super-resolution): if Sentinel-2 passed over the point that day
(UTC date, as in the product name) that scene is used, cloudy or not;
otherwise (no pass, or the point falls in the black swath edge) the nearest
pass within +/- 10 days. A fallback is never silent: it prints
`NOTE ... no usable pass on <date>, used <date>`, the final line counts them,
and `Result.scene_date` holds the date actually used. That date is also in the
file name and the GeoTIFF `scene_date` tag; folder names and the `date` tag
keep the requested date.

Each call writes one folder (and a zip of it) named `output_<date>_<location>`.
If that name is already taken, the next run gets `(1)`, `(2)`, ...
(`output_2026-11-22_Phnom_Penh(1)`). Without `location` the folders are
`output_<date>_run_1`, `output_<date>_run_2`, ... Several dates in one call
give `output_<first>_to_<last>_<location>`.

`run` returns one `Result` per (location, date) with `path` (GeoTIFF),
`scene_date` (acquisition date used),
`preview` (PIL image: 10 m input | 1 m output, centre 1 km) and `error`
(set when that job failed). In Jupyter or Colab, `run` also draws every
preview inline under the progress output; in a plain script it only returns
the results.

The model weights download once to `~/.cache/opensr/` on the first call.
A GPU is used when available; CPU works but is slow.
