Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Automated extraction of NOAA weather satellite images

by jasonk (Parson)
on May 30, 2007 at 13:37 UTC ( #618173=note: print w/replies, xml ) Need Help??


in reply to Automated extraction of NOAA weather satellite images

As it happens, I wrote a very similar script a couple of weeks ago. Rather than using the current time though, mine builds a timestamp from the Last-Modified header of the response, so the timestamp is the last time the image was updated, and you can run it as often as you want without downloading duplicate images.

#!/usr/local/bin/perl -w ################## # Copyright 2007 Jason Kohles (JSK), <email@jasonkohles.com> ################## use strict; use warnings; use LWP::Simple qw( getstore head ); use POSIX 'strftime'; #chdir( "/home/weather/noaa-goes-images" ) or die "Cannot chdir: $!"; for my $loc ( qw( EC WC ) ) { for my $type ( qw( VS IR WV ) ) { my $url = "http://www.goes.noaa.gov/GIFS/".$loc.$type.".JPG"; my $epoch = ( head( $url ) )[ 2 ] || next; my $time = strftime( '%F-%T', gmtime( $epoch ) ); my $file = lc( join( '-', $loc, $type, $time ).'.jpg' ); next if -f $file; print "Retrieving $url to $file\n"; getstore( $url, $file ); } }

We're not surrounded, we're in a target-rich environment!

Replies are listed 'Best First'.
Re^2: Automated extraction of NOAA weather satellite images
by Scott7477 (Chaplain) on May 30, 2007 at 14:14 UTC
    It's a good idea to timestamp the images with Greenwich Mean Time since that's what NOAA uses: I updated my script with your modified timestamp.

    #NOAA updates the images on the GOES website every 30 minutes use strict; use LWP::Simple; use POSIX; my $image; my $url; my %images = ( "eastconusir" => "http://www.goes.noaa.gov/GIFS/ECIR.JPG", "eastconusvis" => "http://www.goes.noaa.gov/GIFS/ECVS.JPG", "eastconuswv" => "http://www.goes.noaa.gov/GIFS/ECWV.JPG", "westconusir" => "http://www.goes.noaa.gov/GIFS/WCIR.JPG", "westconusvis" => "http://www.goes.noaa.gov/GIFS/WCVS.JPG", "westconusvwv" => "http://www.goes.noaa.gov/GIFS/WCWV.JPG", ); foreach my $key (keys %images) { print $key."\n"; my $epoch = ( head( $images{$key} ) )[ 2 ] || next; my $timestring = strftime( "%Y%m%d_%H%M%S", gmtime( $epoch ) ); print $timestring."\n"; print $images{$key}."\n"; my $status = getstore($images{$key},$key.$timestring.".jpg"); print $status."\n" ; };

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://618173]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2021-07-24 12:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?