spacer link to MAST page spacer logo image spacer
 
link to STScI page


Service Outage

On Saturday, July 27, from 11:00 to 21:00 UTC (7 am to 5 pm US Eastern Time), all MAST services will be unavailable due to maintenance.

Sample PHP Scripts

  1. Search HST archive for given RA, Dec and radius. Output requested columns as comma-separated values.


    #!/archive/data1/bin/php -f
    <?php
    #
    # standalone PHP program 
    # (edit top line to point to local PHP executable)
    #
    # Submits GET request to search HST archive for given RA, Dec, and radius,
    # limit results to 10 records, 
    # returns data set name, RA, Dec, and Target name
    # as a comma-separated list
    # prints out column headings and data
    #

    # create GET request

    $request "http://archive.stsci.edu/hst/search.php?";      //quotes url
    $request .= "RA=53.084&DEC=-27.873&radius=1.0&max_records=10&";
    $request .= "outputformat=CSV&action=Search"
    $request .= "&selectedColumnsCsv=sci_data_set_name,sci_ra,sci_dec,sci_targname";

    print 
    "\nrequest = $request \n\n";

    # download results from MAST as an array called $data
    # (ignore errors)

    $data = @file($request);

    # print column headings (skip data types in next row)

    print "$data[0]\n\n";

    # now print search results

    $cnt count($data);
    for (
    $i=2$i<$cnt$i++) print "$data[$i]\n";

    ?>

  2. Search FUSE archive for multiple coordinates. Output comma-separated values with coordinates in decimal degrees.

    #!/archive/data1/bin/php -f
    <?php
    #
    # standalone PHP program 
    # (edit top line to point to local PHP executable)
    #
    # Submits GET request to search FUSE archive 
    # request multiple RA & Dec values
    # (results for each input position will be separated by a blank line)
    # limit each set of results to 10 records, 
    # return columns for data set name, Target name, RA, & Dec
    # output as a comma-separated list with coordinates in decimal degrees
    #

    # create GET request

    $request "http://archive.stsci.edu/fuse/search.php?";      //quotes url
    $request .= "ra=1.514,18.729,42.783&dec=63.679,-72.361,60.418&radius=1.0&max_records=10&";
    $request .= "outputformat=SSV&action=Search&coordformat=dec"
    $request .= "&selectedColumnsCsv=fes_data_set_name,fes_targname,fes_ra_targ,fes_dec_targ";


    # download results from MAST as an array called $data
    # (ignore errors)

    $data = @file($request);

    # print column headings (skip data types in next row)

    print "$data[0]\n";

    # now print search results

    $cnt count($data);
    for (
    $i=2$i<$cnt$i++) print "$data[$i]";
    ?>

  3. Search HST ACS data (both spectra and images) for NGC 1068 observations. Return only science data (i.e., no calibration files). Output comma-separated values with coordinates in decimal degrees.

    #!/usr/local/php5/bin/php -f
    <?php
    #
    # standalone PHP program 
    # (edit top line to point to local PHP executable)
    #
    # request ACS science observations (images and spectra) of NGC 1068
    # (within 3 arcminutes),  return all default columns
    # output as a comma-separated list with coordinates in decimal degrees
    #

    # create GET request

    $request "http://archive.stsci.edu/hst/search.php?";      //quotes url
    $request .= "target=ngc1068&radius=3.0&image[]=ACS&spectrum[]=ACS&";
    $request .= "outputformat=CSV&action=Search&coordformat=dec&"
    $request .= "sci_aec[]=S";

    # print "\nrequest = $request \n\n";

    # download results from MAST as an array called $data
    # (ignore errors)

    $data = @file($request);

    # print column headings (skip data types in next row)

    print "$data[0]\n";

    # now print search results

    $cnt count($data);
    for (
    $i=2$i<$cnt$i++) print "$data[$i]";

    ?>

  4. Search for HST program id 9788 Return only science data. Output comma-separated values with coordinates in decimal degrees.

    #!/usr/local/php5/bin/php -f
    <?php
    #
    # standalone PHP program 
    # (edit top line to point to local PHP executable)
    #
    # request ACS science observations (images and spectra) of NGC 1068
    # (within 3 arcminutes),  return all default columns
    # output as a comma-separated list with coordinates in decimal degrees
    #

    # create GET request

    $request "http://archive.stsci.edu/hst/search.php?";      //quotes url
    $request .= "sci_pep_id=9788&sci_aec[]=S&";
    $request .= "outputformat=CSV&action=Search&coordformat=dec&"
    $request .= "selectedColumnsCsv=sci_pep_id,sci_data_set_name,sci_ra,sci_dec,sci_targname";

    # print "\nrequest = $request \n\n";

    # download results from MAST as an array called $data
    # (ignore errors)

    $data = @file($request);

    # print column headings (skip data types in next row)

    print "$data[0]\n";

    # now print search results

    $cnt count($data);
    for (
    $i=2$i<$cnt$i++) print "$data[$i]";

    ?>