rithwiks commited on
Commit
b10fe46
1 Parent(s): 66f8ed0

sbi script

Browse files
Files changed (1) hide show
  1. SBI-16-2D.py +1 -55
SBI-16-2D.py CHANGED
@@ -155,58 +155,4 @@ class SBI_16_2D(datasets.GeneratorBasedBuilder):
155
  # Process image data from HDU index 4
156
  image_data_4 = hdul[4].data[:, :].tolist()
157
  task_instance_key_4 = f"{self.config.name}-{split}-{idx}-HDU4"
158
- yield task_instance_key_4, {**{"image": image_data_4}, **item}
159
-
160
-
161
-
162
- def make_split_jsonl_files(
163
- config_type="tiny", data_dir="./data", outdir="./splits", seed=42
164
- ):
165
- """
166
- Create jsonl files for the SBI-16-2D dataset.
167
-
168
- config_type: str, default="tiny"
169
- The type of split to create. Options are "tiny" and "full".
170
- data_dir: str, default="./data"
171
- The directory where the FITS files are located.
172
- outdir: str, default="./splits"
173
- The directory where the jsonl files will be created.
174
- seed: int, default=42
175
- The seed for the random split.
176
- """
177
- random.seed(seed)
178
- os.makedirs(outdir, exist_ok=True)
179
-
180
- fits_files = glob(os.path.join(data_dir, "*.fits"))
181
- random.shuffle(fits_files)
182
- if config_type == "tiny":
183
- train_files = fits_files[:2]
184
- test_files = fits_files[2:3]
185
- elif config_type == "full":
186
- split_idx = int(0.8 * len(fits_files))
187
- train_files = fits_files[:split_idx]
188
- test_files = fits_files[split_idx:]
189
- else:
190
- raise ValueError("Unsupported config_type. Use 'tiny' or 'full'.")
191
-
192
- def create_jsonl(files, split_name):
193
- output_file = os.path.join(outdir, f"{config_type}_{split_name}.jsonl")
194
- with open(output_file, "w") as out_f:
195
- for file in files:
196
- print(file, flush=True, end="...")
197
- with fits.open(file, memmap=False) as hdul:
198
- image_id = os.path.basename(file).split(".fits")[0]
199
- ra = hdul["SCI"].header.get("CRVAL1", 0)
200
- dec = hdul["SCI"].header.get("CRVAL2", 0)
201
- pixscale = hdul["SCI"].header.get("CD1_2", 0.396)
202
- item = {
203
- "image_id": image_id,
204
- "image": file,
205
- "ra": ra,
206
- "dec": dec,
207
- "pixscale": pixscale,
208
- }
209
- out_f.write(json.dumps(item) + "\n")
210
-
211
- create_jsonl(train_files, "train")
212
- create_jsonl(test_files, "test")
 
155
  # Process image data from HDU index 4
156
  image_data_4 = hdul[4].data[:, :].tolist()
157
  task_instance_key_4 = f"{self.config.name}-{split}-{idx}-HDU4"
158
+ yield task_instance_key_4, {**{"image": image_data_4}, **item}