In [1]:
from urllib.request import urlretrieve
from urllib.parse import urlparse, urlunparse, urlsplit
from pathlib import Path
In [2]:
from hirise import hirise_tools as ht
In [ ]:
s = 'ESP_012345_1234'
prodid = ht.PRODUCT_ID(s)
prodid.color = 'RED'
In [ ]:
prodid.label_fname
In [ ]:
ht.get_rdr_label(s)
In [ ]:
p = Path.home()
In [ ]:
p
In [ ]:
pid = ht.PRODUCT_ID(s)
In [ ]:
ht.getSourcePathFromID(pid.obsid.s)
In [ ]:
pid.color
In [ ]:
pid.label_storage_path
In [ ]:
ht.get_obsid_from_path(pid.label_storage_path)
In [ ]:
url = ht.HiRISE_URL(s)
In [ ]:
url.rdr_labelpath
In [ ]:
url.rdr_labelurl
In [ ]:
pid.storage_path
In [ ]:
pid.label_storage_path
In [ ]:
p = Path(s)
In [ ]:
p.stem
In [ ]:
p
In [ ]:
url = 'http://hirise-pds.lpl.arizona.edu/PDS/RDR/ESP/ORB_011400_011499/ESP_011491_0985/ESP_011491_0985_RED.LBL'
In [ ]:
hurl = ht.HiRISE_URL()
In [ ]:
hurl.path
In [ ]:
urlparse(url)
In [ ]:
url_root = 'http://hirise-pds.lpl.arizona.edu/download/PDS/RDR'
def get_base_url(idString, color):
"""create base url from obs id"""
sciencePhase, orbitString, targetCode = idString.split("_")
lower = int(orbitString) / 100 * 100
dirname = "_".join(["ORB", str(lower).zfill(6), str(lower + 99).zfill(6)])
basename = idString + '_' + color + '.JP2'
return '/'.join([url_root,sciencePhase,dirname,idString,basename])
In [ ]:
get_base_url('ESP_012345_0985', 'RED')
In [ ]:
class HiRISE_Obsid(object):
def __init__(self, obsid):
phase, orbit, targetcode = obsid.split('_')
self.phase = phase
self.orbit = int(orbit)
self.targetcode = targetcode
def __str__(self):
return '_'.join([self.phase, str(self.orbit).zfill(6),
self.targetcode])
def __repr__(self):
return self.__str__()
In [ ]:
hiobsid = HiRISE_Obsid('ESP_012345_0985')
In [ ]:
hiobsid.targetcode = '1085'
In [ ]:
hiobsid
In [ ]: