aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2016-11-23 19:33:05 +0800
committerAaron LI <aaronly.me@outlook.com>2016-11-23 19:33:05 +0800
commit5ea032ee3ed1fb2084baaa9a2a6eab8261adaaf6 (patch)
tree37dc95b7f5fc191008870acd8a03a8b5ec83e121
parent3beef01f36214973008d980b2da997b053eb4fd8 (diff)
downloadfg21sim-5ea032ee3ed1fb2084baaa9a2a6eab8261adaaf6.tar.bz2
products.py: Add new method "get_product_abspath()"
This new method will be used by the "ProductsAJAXHandler" for the "open" and "download" actions.
-rw-r--r--fg21sim/products.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/fg21sim/products.py b/fg21sim/products.py
index 7613c38..6b83c8b 100644
--- a/fg21sim/products.py
+++ b/fg21sim/products.py
@@ -244,6 +244,40 @@ class Products:
def get_product(self, comp_id, freq_id):
return self.manifest[comp_id][freq_id]
+ def get_product_abspath(self, comp_id, freq_id, ptype="healpix"):
+ """
+ Get the absolute path to the specified product.
+
+ Parameters
+ ----------
+ comp_id : str
+ ID of the component whose product will be checksum'ed
+ freq_id : int
+ The frequency ID of the specific product within the component.
+ ptype : str, optional
+ The type of product whose path will be retrieved.
+ Valid values: ``healpix`` (default), ``hpx``.
+
+ Returns
+ -------
+ abspath : str
+ The absolute path to the specified product
+
+ Raises
+ ------
+ ValueError :
+ Invalid ``ptype`` other than ``healpix`` and ``hpx``.
+ KeyError :
+ The requested product type not available (e.g., the HPX
+ image is not generated yet)
+ """
+ if ptype not in ["healpix", "hpx"]:
+ raise ValueError("Invalid ptype: {0}".format(ptype))
+ curdir = os.path.dirname(self.manifestfile)
+ metadata = self.get_product(comp_id, freq_id)
+ abspath = os.path.join(curdir, metadata[ptype]["path"])
+ return abspath
+
def convert_hpx(self, comp_id, freq_id, clobber=False):
"""
Convert the specified HEALPix map product to HPX projected FITS image.