Skip to content

Commit e129576

Browse files
authored
Merge pull request #25 from lhparker1/patch-1
Document processing steps for Legacy Survey images
2 parents 9d85069 + effc064 commit e129576

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,36 @@ https://app.globus.org/file-manager?origin_id=9fb0fc0e-e760-11ec-9bd2-2d2219dcc1
212212

213213
The directory is organized into south and north surveys, where each survey is split into chunks of 1,000,000 galaxies (sorted by decreasing z-band flux) and saved in hdf5 format. For more details, see [here](https://github.com/georgestein/ssl-legacysurvey/tree/main).
214214

215+
### Processing Legacy Survey Images Directly
216+
217+
If you want to run AstroCLIP on DESI Legacy Survey cutouts that aren’t part of the premade dataset, you only need two preprocessing steps on the g, r, z bands:
218+
219+
1. Center-crop each cutout to 144×144 pixels.
220+
2. Convert the cropped 3-band tensor to display-ready RGB using the `decals_to_rgb` transform below (applied on the g,r,z channels).
221+
222+
The function is defined below:
223+
```python
224+
RGB_SCALES = {
225+
"u": (2, 1.5),
226+
"g": (2, 6.0),
227+
"r": (1, 3.4),
228+
"i": (0, 1.0),
229+
"z": (0, 2.2),
230+
}
231+
232+
def decals_to_rgb(image, bands=["g", "r", "z"], scales=None, m=0.03, Q=20.0):
233+
axes, scales = zip(*[RGB_SCALES[bands[i]] for i in range(len(bands))])
234+
scales = [scales[i] for i in axes]
235+
image = image.movedim(1, -1).flip(-1)
236+
scales = torch.tensor(scales, dtype=torch.float32).to(image.device)
237+
I = torch.sum(torch.clamp(image * scales + m, min=0), dim=-1) / len(bands)
238+
fI = torch.arcsinh(Q * I) / np.sqrt(Q)
239+
I += (I == 0.0) * 1e-6
240+
image = (image * scales + m) * (fI / I).unsqueeze(-1)
241+
image = torch.clamp(image, 0, 1)
242+
return image.movedim(-1, 1)
243+
```
244+
which expects just the g,r,z bands from the Legacy Survey image.
215245

216246
## Pretraining
217247

0 commit comments

Comments
 (0)