downloader (class)

class downloader(log, downloadDirectory=False, settings=False, fits=True, jpeg=False, arcsecSize=60, filterSet='gri', color=True, singleFilters=True, ra=False, dec=False, imageType='stack', mjdStart=False, mjdEnd=False, window=False)[source]

Bases: object

Tools to download the panstarrs image stamps from STScI PanSTARRS image server

Key Arguments

  • log – logger

  • settings – the settings dictionary

  • downloadDirectory – the path to where you want to download the images to. Downlaods to path command is run from by default.

  • fits – download the fits files? Default True

  • jpeg – download the jpeg files? Default False

  • arcsecSize – the size of the image stamps to download (1 arcsec == 4 pixels). Default 60

  • filterSet – the filter set used to create color and/or download as individual stamps. Default gri

  • color – download the color jpeg? Default True

  • singleFilters – download the single filter stmaps? Default False

  • ra – ra in decimal degrees.

    • dec – dec in decimal degrees.

    • imageType – warp or stacked images? Default stack

    • mjdStart – the start of a time-window within which the images required are taken. Default False (everything)

    • mjdEnd – the end of a time-window within which the images required are taken. Default False (everything)

Usage

The following will return 3 lists of paths to local fits, jpeg and color-jpeg files:

from panstamps.downloader import downloader
fitsPaths, jpegPaths, colorPath = downloader(
    log=log,
    settings=False,
    fits=False,
    jpeg=True,
    arcsecSize=600,
    filterSet='gri',
    color=True,
    singleFilters=True,
    ra="70.60271",
    dec="-21.72433",
    imageType="stack",
    mjdStart=False,
    mjdEnd=False,
    window=False
).get()

Methods

get()

download the requested jpegs and fits files

get_html_content()

Build the URL for the stamp request and extract the HTML content

parse_html_for_image_urls_and_metadata(content)

parse html for image urls and metadata

get()[source]

download the requested jpegs and fits files

Return

  • fitsPaths – a list of local paths to downloaded fits files

  • jpegPaths – a list of local paths to downloaded jpeg files

  • colorPath – a list of local paths to downloaded color jpeg file (just one image)

get_html_content()[source]

Build the URL for the stamp request and extract the HTML content

Return

  • content – the HTML content of the requested URL

  • status_code – the HTTP status code of the request response

  • url – the URL requested from the PS1 stamp server

Usage

from panstamps.downloader import downloader
content, status_code, url = downloader(
    log=log,
    settings=False,
    fits=False,
    jpeg=True,
    arcsecSize=600,
    filterSet='gri',
    color=True,
    singleFilters=True,
    ra="70.60271",
    dec="-21.72433",
    imageType="stack",
    mjdStart=False,
    mjdEnd=False,
    window=False
).get_html_content() 

print(status_code)
# OUT: 200

print(url)
# OUT: http://ps1images.stsci.edu/cgi-bin/ps1cutouts?filter=gri&filter=color&catlist=&autoscale=99.500000&verbose=0&output_size=2400&filetypes=stack&pos=70.60271+-21.72433&size=2400
parse_html_for_image_urls_and_metadata(content)[source]

parse html for image urls and metadata

Key Arguments

  • content – the content of the requested PS1 stamp HTML page

Usage

Note if you want to constrain the images you download with a temporal window then make sure to given values for mjdStart and mjdEnd.

from panstamps.downloader import downloader
mydownloader = downloader(
    log=log,
    settings=False,
    fits=False,
    jpeg=True,
    arcsecSize=600,
    filterSet='gri',
    color=True,
    singleFilters=True,
    ra="70.60271",
    dec="-21.72433",
    imageType="stack",
    mjdStart=False,
    mjdEnd=False,
    window=False
)
content, status_code, url = mydownloader.get_html_content() 

allStacks, allWarps, colorImage = mydownloader.parse_html_for_image_urls_and_metadata(content=content)

for k,v in allStacks.items():
    print(k, v)

# OUT:
## jpegs ['http://ps1images.stsci.edu/cgi-bin/fitscut.cgi?red=/data/ps1/node15/stps15.1/nebulous/23/3a/7187453864.gpc1%3ALAP.PV3.20140730%3A2015%3A01%3A29%3ARINGS.V3%3Askycell.0812.050%3ARINGS.V3.skycell.0812.050.stk.4297354.unconv.fits&x=70.602710&y=-21.724330&size=2400&wcs=1&asinh=True&autoscale=99.500000&output_size=2400', 'http://ps1images.stsci.edu/cgi-bin/fitscut.cgi?red=/data/ps1/node08/stps08.1/nebulous/de/fa/5761784572.gpc1%3ALAP.PV3.20140730%3A2014%3A12%3A25%3ARINGS.V3%3Askycell.0812.050%3ARINGS.V3.skycell.0812.050.stk.4106421.unconv.fits&x=70.602710&y=-21.724330&size=2400&wcs=1&asinh=True&autoscale=99.500000&output_size=2400', 'http://ps1images.stsci.edu/cgi-bin/fitscut.cgi?red=/data/ps1/node08/stps08.1/nebulous/1b/d7/5756633973.gpc1%3ALAP.PV3.20140730%3A2014%3A12%3A25%3ARINGS.V3%3Askycell.0812.050%3ARINGS.V3.skycell.0812.050.stk.4097309.unconv.fits&x=70.602710&y=-21.724330&size=2400&wcs=1&asinh=True&autoscale=99.500000&output_size=2400']
## fits ['http://ps1images.stsci.edu/cgi-bin/fitscut.cgi?red=/data/ps1/node15/stps15.1/nebulous/23/3a/7187453864.gpc1:LAP.PV3.20140730:2015:01:29:RINGS.V3:skycell.0812.050:RINGS.V3.skycell.0812.050.stk.4297354.unconv.fits&format=fits&x=70.602710&y=-21.724330&size=2400&wcs=1&imagename=cutout_rings.v3.skycell.0812.050.stk.g.unconv.fits', 'http://ps1images.stsci.edu/cgi-bin/fitscut.cgi?red=/data/ps1/node08/stps08.1/nebulous/de/fa/5761784572.gpc1:LAP.PV3.20140730:2014:12:25:RINGS.V3:skycell.0812.050:RINGS.V3.skycell.0812.050.stk.4106421.unconv.fits&format=fits&x=70.602710&y=-21.724330&size=2400&wcs=1&imagename=cutout_rings.v3.skycell.0812.050.stk.r.unconv.fits', 'http://ps1images.stsci.edu/cgi-bin/fitscut.cgi?red=/data/ps1/node08/stps08.1/nebulous/1b/d7/5756633973.gpc1:LAP.PV3.20140730:2014:12:25:RINGS.V3:skycell.0812.050:RINGS.V3.skycell.0812.050.stk.4097309.unconv.fits&format=fits&x=70.602710&y=-21.724330&size=2400&wcs=1&imagename=cutout_rings.v3.skycell.0812.050.stk.i.unconv.fits']
## filters ['g', 'r', 'i']
## filenames ['stack_g_ra70.602710_dec-21.724330_arcsec600_skycell0812.050', 'stack_r_ra70.602710_dec-21.724330_arcsec600_skycell0812.050', 'stack_i_ra70.602710_dec-21.724330_arcsec600_skycell0812.050']

Return

  • allStacks – dictionary of 4 equal length lists. jpeg remote urls, fits remote urls, filters and filenames.

  • allWarps – dictionary of 4 equal length lists. jpeg remote urls, fits remote urls, filters and filenames.

  • colorImage – dictionary of 4 equal length lists. jpeg remote urls, fits remote urls, filters and filenames.