Galaxy Zoo Talk

Automating the saving of SDSS images - can any reader help please?

  • JeanTate by JeanTate

    Is there a zooite who can help me with this (apparently) straight-forward problem?

    Suppose I want to create a 500x500 pix SDSS image of SDSS J120209.28+132922.8 (ObjId 1237661813883601750), with an image scale of 0.2"/pix. The URL for this is actually pretty straight-forward (DR10 here):

    http://skyservice.pha.jhu.edu/DR10/ImgCutout/getjpeg.aspx?ra=180.5387&dec=13.4897&scale=0.2&width=500&height=500
    

    And putting this URL in the standard Talk image wrapper displays the image here, in this Talk post:

    enter image description here

    I can right-click on it, and save the image as, for example, LBR1034.jpg (assume that means something to me).

    But how can I go from the URL to saved image LBR1034.jpg, without using Talk, and without manually right-clicking? Important if I want to process a few thousand objects (given their coordinates) ...

    Posted

  • mlpeck by mlpeck

    Jean:

    Try wget. It's a command line tool and native to Unix/Linux, but there's a Windows version. I've written some simple minded shell scripts to do bulk downloads of SDSS spectra that can probably be adapted.

    Posted

  • c_cld by c_cld in response to JeanTate's comment.

    As you are a Python user, see a solution in

    http://stackoverflow.com/questions/24915611/save-images-from-urls-stored-in-list-python-simple

    Posted

  • JeanTate by JeanTate

    Thanks mlpeck, C_cld! 😄

    I installed wget from cygwin, and after some trial and error, can create a Windows .bat file (for use with the command line, in cmd), each line of which is a separate wget command, with an output jpg file (took a while to recognize the difference between -o and -O ). I can create the batch files easily enough; however, I haven't yet worked out how to a) fire up wget from anywhere (the bin directory in cygwin64 is where the binary lives), and b) send the output to a directory other than the one I'm in ... (ah the joys of Windows ...)

    Python? Yep, something to work on when I have time ...

    Thanks again.

    Posted

  • mlpeck by mlpeck in response to JeanTate's comment.

    I haven't yet worked out how to a) fire up wget from anywhere (the
    bin directory in cygwin64 is where the binary lives)

    Jean:

    You just need to edit the path to include the directory that wget lives in. To do that (in Windows 7 at least) go to the control panel, click on "System", click on "Advanced system settings" and select the "Advanced" tab if necessary, click on "Environment Variables...", select Path in the User variables window, and click Edit. Easy, right?

    I wrote a short Python function to create a shell script to automate image cutout downloads if anyone else is interested. There's no documentation -- not even a docstring -- and a few minor edits would be needed to use it in Windows. Here's the link: https://www.dropbox.com/s/3a0mvvx21dvcrli/wget_batch.py?dl=0

    Posted

  • c_cld by c_cld

    Running Python 2.7 on windows 7,
    I've used https://github.com/juandesant/DownloadSDSSFindingCharts with a few difficulties on "win" infile format (easier to end lines by ^l rather than ^p as in linux).
    If the object is the SDSS ObjId, I input '123xxxx instead of 123xxx to have type string without forgetting option -m SDSS_COORDINATES to avoid sesame query of wich url need to be updated.

    My example of SDSS gallery of imaged gravitational #lensing systems.

    Have a good trial

    Posted

  • JeanTate by JeanTate

    Thanks mlpeck, C_cld.

    I ended up writing a Python program that uses urllib.urlretrieve, and in the process learned some stuff about how to read from a (text) file, deal with \n, and so on (I always knew I would have to learn this, but kept putting it off; it's so, um, messy). It's a pretty simple program, if rather inelegant.

    Posted