Skip to content

Commit

Permalink
Clean up rotate script a bit and add output to better record what hap…
Browse files Browse the repository at this point in the history
…pened
  • Loading branch information
JoanneBogart committed Feb 7, 2024
1 parent e78f0d9 commit 53d4786
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions skycatalogs/scripts/rotate.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import os
import time
import healpy
import logging # expected by make_galaxy_schema
import numpy as np
import pandas as pd
import pyarrow as pa
import pyarrow.parquet as pq
# Following imports were used in old GCR_siminterface rotate class
# from lsst.sims.utils import angularSeparation
# from lsst.sims.utils import rotationMatrixFromVectors
# from lsst.sims.utils import cartesianFromSpherical, sphericalFromCartesian

# Possible alternatives are in rubin_schedule.utils.coordinate_transformations
#
from rubin_scheduler.utils import cartesian_from_spherical, spherical_from_cartesian
from rubin_scheduler.utils import rotation_matrix_from_vectors, angular_separation
from skycatalogs.skyCatalogs import open_catalog
Expand Down Expand Up @@ -213,6 +206,7 @@ def output_field_pixels(self, output_dir, arrow_schema):
# Now write out healpixels for this collection (sets of healpixels
# belonging to different fields are disjoint)
# for hp in hps_distinct:
print('Generating data for pixels ', field_distinct)
for hp in field_distinct:
outpath = os.path.join(output_dir, f'galaxy_{hp}.parquet')
writer = pq.ParquetWriter(outpath, arrow_schema)
Expand All @@ -237,7 +231,11 @@ def output_field_pixels(self, output_dir, arrow_schema):
cat = open_catalog(input_config)
NSIDE = 32 # should really read from config

for dc2_ra, dc2_dec, f_ra, f_dec, name in zip(DC2_RA, DC2_DEC, FIELD_RA, FIELD_DEC, FIELD_NAMES):
# For Ops rehearsal Did first field in a separate run
# for dc2_ra, dc2_dec, f_ra, f_dec, name in zip(DC2_RA[1:], DC2_DEC[1:], FIELD_RA[1:],
# FIELD_DEC[1:], FIELD_NAMES[1:]):
for dc2_ra, dc2_dec, f_ra, f_dec, name in zip(DC2_RA, DC2_DEC, FIELD_RA,
FIELD_DEC, FIELD_NAMES):
disk = Disk(dc2_ra, dc2_dec, DISK_RADIUS_DG * 3600)
obj_list = cat.get_object_type_by_region(disk, 'galaxy')
print('Field ', name)
Expand All @@ -248,5 +246,5 @@ def output_field_pixels(self, output_dir, arrow_schema):
galaxy_schema = make_galaxy_schema('rotate_logger')
galaxy_rotator = GalaxyRotator(rotator, name, obj_list)
galaxy_rotator.output_field_pixels(rotated_dir, galaxy_schema)

break ### for testing stop after 1 field
print('Completed field ', name)
# break ### for testing stop after 1 field

0 comments on commit 53d4786

Please sign in to comment.