An automatation script to download multiple dates from the rapidfire website.
#!/usr/bin/perl # wget script for downloading sequences from rapidfire satellite. #
#http://rapidfire.sci.gsfc.nasa.gov/subsets/?AERONET_FORTH_CRETE/2007237/AERONET_FORTH_CRETE.2007237.aqua.250m.jpg
#server $server = "http://rapidfire.sci.gsfc.nasa.gov";
$subset = "AERONET_FORTH_CRETE";
$date = 2007237;
$filename = "AERONET_FORTH_CRETE";
$instrument = "aqua";
$resolution = "250m";
$filetype = "jpg"; ######### #select satelite" ######### @SAT_SELECT; open ( SAT_IN, "satelite.list"); while (defined($line = <SAT_IN>)) {
$num++; push(@SAT_LIST,$line ); #chomp removes the line character.
print "$num-$line"; } print STDOUT ("\n Select which subset? Type the number: "); $SAT_SELECT= <STDIN>; $subset= @SAT_LIST[$SAT_SELECT-1]; $subset_name = chomp($subset); #chomp removes the line character.
print "\nSELECTED subset: $subset"; ######## #SELECT DATESTART - DATE END ######## print STDOUT ("\n Select starting date (ddmmyyyy): "); $START_DATE= <STDIN>; $start_day=substr($START_DATE, 0, 2); $start_month=substr($START_DATE, 2, 2); $start_year=substr($START_DATE, 4, 4); $START = &getJulianDate($START_DATE, "start");
print STDOUT ("\n Select ending date (ddmmyyyy): "); $END_DATE= <STDIN>; $end_day=substr($END_DATE, 0, 2); $end_month=substr($END_DATE, 2, 2); $end_year=substr($END_DATE, 4, 4); $END = &getJulianDate($END_DATE, "end");
if($end_year<$start_year) { print "end date is greater than start date!!!!!"; #exit 1; } elsif ($end_year==$start_year) { for ($count = $START ; $count <= $END ; $count++) { $imagenum = &subsetsize($count); $date = "$start_year$imagenum";
$file="$server/subsets/$subset/$date/$subset.$date.$instrument.$resolution.$filetype"; #print "downloading file: $file\n"; $download = `wget --tries=5 $file --output-file=log.txt --debug`; print $download; } } elsif($end_year>$start_year) { print "sorry enter for only one year- (to fix)" ;
}
################################ #fix subset string size ################################ sub subsetsize { local($value); $value = "$_[0]";
if(length ($value)==1) { $value = "00$value"; }elsif(length ($value)==2) { $value = "0$value"; } return $value; } ################################ #GET JULIAN DATE SUBROUTINE ################################ sub getJulianDate { local($fsign, $fjd, $ttime, $tday , $tmonth , $tyear, $fjd_startyear); #date format (ddmmyyyy); $ttime = 24; #substr( $variable, start, length); $tday=substr($_[0], 0, 2); $tmonth=substr($_[0], 2, 2);
$tyear=substr($_[0], 4, 4);
# print "\nSELECTED $_[1]ing day: $tday, month: $tmonth and year: $tyear"; $fsign = (100*$tyear+ $tmonth-190002.5); if ($fsign>=0){ $fsign = 1; }else{ $fsign = -1; } $n1 = (367*$tyear); $n2 =(((7*($tyear+((($tmonth+9)/12) )))/4)); $n3 = ((275*$tmonth)/9); $fjd = $n1 - $n2+ $n3 + $tday + 1721013.5 + $ttime/24 - 0.5 +($fsign) + 0.5; #Conversion from a Julian date to a Gregorian calendar date. # print $fjd; $tday = 1; $tmonth =1; $fsign = (100*$tyear+ $tmonth-190002.5); if ($fsign>=0){ $fsign = 1; }else{ $fsign = -1; } $n1 = (367*$tyear); $n2 =(((7*($tyear+((($tmonth+9)/12) )))/4)); $n3 = ((275*$tmonth)/9); $fjd_startyear = $n1 - $n2+ $n3 + $tday + 1721013.5 + $ttime/24 - 0.5 +($fsign) + 0.5; #Conversion from a Julian date to a Gregorian calendar date.
# print int($fjd- $fjd_startyear + 1); return int($fjd- $fjd_startyear + 1); } |