Created
November 5, 2011 00:48
-
-
Save andrewharvey/1340891 to your computer and use it in GitHub Desktop.
Fetches BOM.gov.au radar images giving us a local mirror, including historical data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
# Fetches BOM.gov.au radar images giving us a local mirror, including historical | |
# data. | |
# | |
# Radar images are updated every 10 minutes, but the BOM only keep the last | |
# hour and 10 minutes worth of radar images on their FTP server. With this in | |
# mind I would recommend running this script anywhere from minutely to hourly. | |
# | |
# This script is licensed CC0 by Andrew Harvey <andrew.harvey4@gmail.com> | |
# | |
# To the extent possible under law, the person who associated CC0 | |
# with this work has waived all copyright and related or neighboring | |
# rights to this work. | |
# http://creativecommons.org/publicdomain/zero/1.0/ | |
use strict; | |
use Net::FTP; | |
## config | |
# which radar sites do we want to fetch | |
my @sites = ('IDR713'); | |
# where to save the radar images on the local side | |
my $datadir = "data/"; | |
# login to the BOM FTP site | |
my $ftp = Net::FTP->new('ftp.bom.gov.au', Debug => 0) or die; | |
$ftp->login("anonymous", '-anonymous@') or die; | |
# move into the radar folder | |
$ftp->cwd("/anon/gen/radar") or die; | |
# get a list of all files in the current directory | |
my @files = $ftp->ls() or die; | |
my $fetchCount = 0; | |
# for each site, find the all the radar images on the FTP server | |
for my $site (@sites) { | |
my @radarTs = grep(/^${site}\.T\./, @files); | |
for my $radarT (@radarTs) { | |
# fetch all new radar images | |
my $localFile = "$datadir$site/$radarT"; | |
if (! -e $localFile ) { | |
print "FTP GET $radarT\n"; | |
mkdir "$datadir/$site"; | |
$ftp->get($radarT, $localFile) or die; | |
$fetchCount++; | |
} | |
} | |
} | |
print "Fetched $fetchCount new radar images.\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
# Fetches BOM.gov.au radar images transparencies giving us a local mirror. | |
# | |
# This script is licensed CC0 by Andrew Harvey <andrew.harvey4@gmail.com> | |
# | |
# To the extent possible under law, the person who associated CC0 | |
# with this work has waived all copyright and related or neighboring | |
# rights to this work. | |
# http://creativecommons.org/publicdomain/zero/1.0/ | |
use strict; | |
use Net::FTP; | |
use JSON; | |
# which radar sites do we want to fetch | |
my @sites = ('IDR032', 'IDR033', 'IDR034', 'IDR03I', 'IDR712', 'IDR713', 'IDR714', 'IDR71I'); | |
# where to save the radar images on the local side | |
my $datadir = "data/"; | |
mkdir $datadir; | |
# login to the BOM FTP site | |
my $ftp = Net::FTP->new('ftp.bom.gov.au', Debug => 0) or die; | |
$ftp->login("anonymous", '-anonymous@') or die; | |
# move into the radar folder | |
$ftp->cwd("/anon/gen/radar_transparencies") or die; | |
# get a list of all files in the current directory | |
my @files = $ftp->ls() or die; | |
my $fetchCount = 0; | |
# for each site, find the all the radar images on the FTP server | |
for my $site (@sites) { | |
my @radarTs = grep(/^${site}\./, @files); | |
for my $radarT (@radarTs) { | |
# fetch all new radar images | |
my $localFile = "$datadir$site/$radarT"; | |
if (! -e $localFile ) { | |
print "FTP GET $radarT\n"; | |
mkdir "$datadir/$site"; | |
$ftp->get($radarT, $localFile) or die; | |
$fetchCount++; | |
} | |
} | |
} | |
print "Fetched $fetchCount new radar transparencies.\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you are not getting valid png files, try using
before