Документ взят из кэша поисковой машины. Адрес оригинального документа : http://vo.astronet.ru/ws/wcsfix/
Дата изменения: Unknown
Дата индексирования: Mon Oct 1 19:51:45 2012
Кодировка:

Поисковые слова: п п п п п п п п р п р п р п р п р п р п р п р п р п р п
SAI Web Services - WCSfix

WCS Fix - fixing the World Coordinate System in FITS files

This service aims to automatically match stars in FITS image provided with catalogue and add the correct WCS keywords to its FITS header. Three interfaces are are provided.

SOAP web service

To use it, you has to provide the image as a Base64-encoded string, along with the rough information on image field of view size and center (the latter may be deduced from FITS header keywords like 'RA' and 'DEC'). Also, you may specify the catalog name to match with (Tycho2 and USNO A-2 are now supported).

The service has the following public methods:

  • string matchLists(string list1, string list2) - matches two lists of objects with different coordinate systems, and returns the corresponding coordinate transformation parameters (as a set of FITS keywords). Lists have to be two- or three-columns strings with coordinates and brightness (in stellar magnitudes, i.e. the lower the brighter!), correspondingly.
  • string getStars(string image_base64, string params) - performs the extraction of stars from base64-encoded image using the SExtractor program. You may provide the set of parameters you wish to get (consult SExtractor manual for its description).
  • string fixWcs(string image_base64, double sr, double ra, double dec, double catalogue) - the main service itself. Performs automatic matching of Base64-encoded FITS image and returns it with WCS keywords inserted. You need to provide the rough size of image sr (in degrees). Optional parameters are the rough center coordinates ra and dec (it will try to guess them from FITS header) and catalogue name to match with (it will try to guess it from size of image - i.e. Tycho2 for wide field images, and USNO A-2 for narrow field ones).

Below is the simple example on how to access the service from Perl with SOAP::Lite module.

#!/usr/bin/perl -w

use SOAP::Lite;
use MIME::Base64;

$s = SOAP::Lite
    -> service('http://vo.astronet.ru/ws/wcsfix/wcsfix.wsdl');

$sr = 15;      # Radius, in degrees
$ra = 12.54;   # Center RA and Dec
$dec = -32.5;  # in degrees

my $string = read_file('image_without_wcs.fits');
my $base64_string = MIME::Base64::encode_base64($string);
my $result = $s->fixWCS($base64_string, $sr, $ra, $dec);

write_file("image_with_wcs.fits", MIME::Base64::decode_base64($result));

# Below are some support routines, you don't need to use it in your code

sub read_file
{
    my ( $f ) = @_;
    open F, "< $f" or die "Can't open $f : $!";
    my @f = <F>;
    close F;
    
    return join("", @f);
}

sub write_file
{
    my ( $f, @data ) = @_;
    @data = () unless @data;
    open F, "> $f" or die "Can't open $f : $!";
    print F @data;

    close F;
}

HTTP POST service

To access HTTP POST service, you need to upload the image and set query parameters in the same way as described behind. The names of parameters are file, sr, and (optionally) ra, dec and catalog. In reply, the service sends either fixed image with application/fits MIME-type, or error message with text/html one. The example code to access the service is below. It uses the Perl LWP module.
#!/usr/bin/perl -w

use HTTP::Request::Common;
use LWP;

my $ra = 0.12;
my $dec = 5.6;
my $sr = 10;
my $catalog = 'usnob1';

my $file = 'image.fits';
my $fixed_file = 'image_fixed.fits';

my $service = 'http://vo.astronet.ru/wcsfix/wcsfix_post.cgi';

$useragent = LWP::UserAgent->new;
    
my $request =
    POST $service,
    Content_Type => 'multipart/form-data',
    Content => [
        file => [$file],
        ra => $ra,
        dec => $dec,
        sr => $sr,
        catalog => $catalog
    ];

my $response = $useragent->request($request);

if($response->is_success){
    if($response->header('Content-Type') eq 'application/fits'){
        print "FITS file received\n";

        open(FILE, ">$fixed_file") or die "Can't open output file for writing!\n";
        print FILE $response->content;
        close(FILE);
    } else {
        print "Service replied: ".$response->content;
    }
} else {
    print "An error occured: ".$response->status_line."\n";
}