|
lsst.pipe.tasks g540474b770+e939cf0e26
|
Classes | |
| class | AllSkyHipsTaskConnections |
Variables | |
| Iterable | low_order_metadata [TaskMetadata] |
| array | hpx11_pixels -like |
| max_order : `int` | |
| pixels : `np.ndarray` (N,) | |
| shift_order : `int` | |
| band : `str` | |
| properties_config : `lsst.pipe.tasks.hips.HipsPropertiesConfig` | |
| area : `float` | |
| initial_ra : `float` | |
| initial_dec : `float` | |
| initial_fov : `float` | |
| min_uniq_order : `int`, optional | |
| allsky_order : `int` | |
| lsst.pipe.tasks.rgb2hips._all_sky_hips.allsky_order : `int` |
# WARNING: In general PipelineTasks are not allowed to do any outputs
# outside of the butler. This task has been given (temporary)
# Special Dispensation because of the nature of HiPS outputs until
# a more controlled solution can be found.
# Make a healsparse map which provides easy degrade/comparisons.
hspmap = hsp.HealSparseMap.make_empty(2**min_uniq_order, 2**max_order, dtype=np.int8)
hspmap[pixels] = 1
uri = self.hips_base_path.join("Moc.fits")
with ResourcePath.temporary_uri(suffix=uri.getExtension()) as temporary_uri:
hspmap.write_moc(temporary_uri.ospath)
uri.transfer_from(temporary_uri, transfer="copy", overwrite=True)
def _write_allsky_file(self, allsky_order):
Definition at line 434 of file _all_sky_hips.py.
| lsst.pipe.tasks.rgb2hips._all_sky_hips.area : `float` |
Definition at line 296 of file _all_sky_hips.py.
| lsst.pipe.tasks.rgb2hips._all_sky_hips.band : `str` |
Definition at line 231 of file _all_sky_hips.py.
| array lsst.pipe.tasks.rgb2hips._all_sky_hips.hpx11_pixels -like |
Definition at line 206 of file _all_sky_hips.py.
| lsst.pipe.tasks.rgb2hips._all_sky_hips.initial_dec : `float` |
Definition at line 300 of file _all_sky_hips.py.
| lsst.pipe.tasks.rgb2hips._all_sky_hips.initial_fov : `float` |
Definition at line 302 of file _all_sky_hips.py.
| lsst.pipe.tasks.rgb2hips._all_sky_hips.initial_ra : `float` |
Definition at line 298 of file _all_sky_hips.py.
| Iterable lsst.pipe.tasks.rgb2hips._all_sky_hips.low_order_metadata [TaskMetadata] |
_DefaultName = "allSkyHipsTask"
ConfigClass = AllSkyHipsTaskConfig
config: ConfigClass
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.hips_base_path = ResourcePath(self.config.hips_base_uri, forceDirectory=True)
self.hips_base_path = self.hips_base_path.join(
f"color_{self.config.color_ordering}", forceDirectory=True
)
def runQuantum(
self,
butlerQC: QuantumContext,
inputRefs: InputQuantizedConnection,
outputRefs: OutputQuantizedConnection,
) -> None:
# Extract the healpix8 pixel ids.
hpx8_pixels = []
for ref in inputRefs.input_hips:
hpx8_pixels.append((ref.dataId["healpix8"]))
# Scale pixel IDS to higher order (hpx11) that were already produced
hpx8_rangeset = RangeSet(hpx8_pixels)
hpx11_rangeset = hpx8_rangeset.scaled(4**3)
hpx11_pixels = set()
for begin, end in hpx11_rangeset:
hpx11_pixels.update(range(begin, end))
hpx11_pixels = np.array([s for s in hpx11_pixels])
low_order_metadata = butlerQC.get(inputRefs.low_order_metadata)
outputs = self.run(low_order_metadata, hpx11_pixels)
butlerQC.put(outputs, outputRefs)
def run(self, low_order_metadata: Iterable[TaskMetadata], hpx11_pixels) -> Struct:
Definition at line 204 of file _all_sky_hips.py.
| lsst.pipe.tasks.rgb2hips._all_sky_hips.max_order : `int` |
self._write_properties_and_moc(
self.config.max_order, hpx11_pixels, self.config.shift_order, self.config.color_ordering
)
self._write_allsky_file(self.config.min_order)
return Struct()
def _write_properties_and_moc(self, max_order, pixels, shift_order, band):
match self.config.data_bitpix:
case "float64":
bitpix = -64
case "float32":
bitpix = -32
case "uint8":
bitpix = 8
case "uint16":
bitpix = 16
case "uint32":
bitpix = 32
case "uint64":
bitpix = 64
match self.config.hips_bitpix:
case "float64":
hbitpix = -64
case "float32":
hbitpix = -32
case "uint8":
hbitpix = 8
case "uint16":
hbitpix = 16
case "uint32":
hbitpix = 32
case "uint64":
hbitpix = 64
date_iso8601 = datetime.utcnow().isoformat(timespec="seconds") + "Z"
pixel_scale = hpg.nside_to_resolution(2 ** (max_order + shift_order), units="degrees")
uri = self.hips_base_path.join("properties")
with ResourcePath.temporary_uri(suffix=uri.getExtension()) as temporary_uri:
with open(temporary_uri.ospath, "w") as fh:
_write_property(
fh,
"creator_did",
properties_config.creator_did_template.format(band=band),
)
if properties_config.obs_collection is not None:
_write_property(fh, "obs_collection", properties_config.obs_collection)
_write_property(
fh,
"obs_title",
properties_config.obs_title_template.format(band=band),
)
if properties_config.obs_description_template is not None:
_write_property(
fh,
"obs_description",
properties_config.obs_description_template.format(band=band),
)
if len(properties_config.prov_progenitor) > 0:
for prov_progenitor in properties_config.prov_progenitor:
_write_property(fh, "prov_progenitor", prov_progenitor)
if properties_config.obs_ack is not None:
_write_property(fh, "obs_ack", properties_config.obs_ack)
_write_property(fh, "obs_regime", "Optical")
_write_property(fh, "data_pixel_bitpix", str(bitpix))
_write_property(fh, "dataproduct_type", "image")
_write_property(fh, "moc_sky_fraction", str(area / 41253.0))
_write_property(fh, "data_ucd", "phot.flux")
_write_property(fh, "hips_creation_date", date_iso8601)
_write_property(fh, "hips_builder", "lsst.pipe.tasks.hips.GenerateHipsTask")
_write_property(fh, "hips_creator", "Vera C. Rubin Observatory")
_write_property(fh, "hips_version", "1.4")
_write_property(fh, "hips_release_date", date_iso8601)
_write_property(fh, "hips_frame", "equatorial")
_write_property(fh, "hips_order", str(max_order))
_write_property(fh, "hips_tile_width", str(2**shift_order))
_write_property(fh, "hips_status", "private master clonableOnce")
_write_property(fh, "hips_tile_format", self.config.file_extension)
_write_property(fh, "dataproduct_subtype", "color")
_write_property(fh, "hips_pixel_bitpix", str(hbitpix))
_write_property(fh, "hips_pixel_scale", str(pixel_scale))
_write_property(fh, "hips_initial_ra", str(initial_ra))
_write_property(fh, "hips_initial_dec", str(initial_dec))
_write_property(fh, "hips_initial_fov", str(initial_fov))
if self.config.bluest_band in properties_config.spectral_ranges:
em_min = properties_config.spectral_ranges[self.config.bluest_band].lambda_min / 1e9
else:
self.log.warning("blue band %s not in self.config.spectral_ranges.", band)
em_min = 3e-7
if self.config.reddest_band in properties_config.spectral_ranges:
em_max = properties_config.spectral_ranges[self.config.reddest_band].lambda_max / 1e9
else:
self.log.warning("red band %s not in self.config.spectral_ranges.", band)
em_max = 1e-6
_write_property(fh, "em_min", str(em_min))
_write_property(fh, "em_max", str(em_max))
if properties_config.t_min is not None:
_write_property(fh, "t_min", properties_config.t_min)
if properties_config.t_max is not None:
_write_property(fh, "t_max", properties_config.t_max)
uri.transfer_from(temporary_uri, transfer="copy", overwrite=True)
def _write_hips_moc_file(self, max_order, pixels, min_uniq_order=1):
Definition at line 225 of file _all_sky_hips.py.
| lsst.pipe.tasks.rgb2hips._all_sky_hips.min_uniq_order : `int`, optional |
Definition at line 412 of file _all_sky_hips.py.
| lsst.pipe.tasks.rgb2hips._all_sky_hips.pixels : `np.ndarray` (N,) |
Definition at line 227 of file _all_sky_hips.py.
| lsst.pipe.tasks.rgb2hips._all_sky_hips.properties_config : `lsst.pipe.tasks.hips.HipsPropertiesConfig` |
area = hpg.nside_to_pixel_area(2**max_order, degrees=True) * len(pixels)
initial_ra = self.config.properties.initial_ra
initial_dec = self.config.properties.initial_dec
initial_fov = self.config.properties.initial_fov
if initial_ra is None or initial_dec is None or initial_fov is None:
# We want to point to an arbitrary pixel in the footprint.
# Just take the median pixel value for simplicity.
temp_pixels = pixels.copy()
if temp_pixels.size % 2 == 0:
temp_pixels = np.append(temp_pixels, [temp_pixels[0]])
medpix = int(np.median(temp_pixels))
_initial_ra, _initial_dec = hpg.pixel_to_angle(2**max_order, medpix)
_initial_fov = hpg.nside_to_resolution(2**max_order, units="arcminutes") / 60.0
if initial_ra is None or initial_dec is None:
initial_ra = _initial_ra
initial_dec = _initial_dec
if initial_fov is None:
initial_fov = _initial_fov
self._write_hips_properties_file(
self.config.properties,
band,
max_order,
shift_order,
area,
initial_ra,
initial_dec,
initial_fov,
)
# Write the MOC coverage
self._write_hips_moc_file(
max_order,
pixels,
)
def _write_hips_properties_file(
self,
properties_config,
band,
max_order,
shift_order,
area,
initial_ra,
initial_dec,
initial_fov,
):
Definition at line 288 of file _all_sky_hips.py.
| lsst.pipe.tasks.rgb2hips._all_sky_hips.shift_order : `int` |
Definition at line 229 of file _all_sky_hips.py.