4 # A really crappy code to grab last 8 Kp values....
11 ($Year, $Month, $Day) = &year_month_day
();
13 if (-e
"/tmp/DGD.txt"){
14 unlink("/tmp/DGD.txt");
17 if (-e
"/tmp/curind.txt"){
18 unlink("/tmp/curind.txt");
22 $grabcmd = "cd /tmp; wget --passive-ftp --tries 2 -q ftp://ftp.swpc.noaa.gov/pub/latest/DGD.txt";
27 # ensure that there are at least 8 values available...
40 open(TmpFile
, "/tmp/DGD.txt");
43 if ($_ =~ /^\d{4} \d{2} \d{2}\s*\d*/ ){
47 s/^(\d{4}) (\d{2}) (\d{2}).*\s{2,}(.*)/\4/;
48 s/([ -]{0,1}\d{1,2})([ -]{0,1}\d{1,2})([ -]{0,1}\d{1,2})([ -]{0,1}\d{1,2})([ -]{0,1}\d{1,2})([ -]{0,1}\d{1,2})([ -]{0,1}\d{1,2})([ -]{0,1}\d{1,2})/\1 \2 \3 \4 \5 \6 \7 \8/;
50 $Date =~ s/^(\d{4}) (\d{2}) (\d{2}).*\s{2,}(.*)/\1\2\3/;
51 ($a, $b, $c, $d, $e, $f, $g, $h) = split(/\s{1,}/, $_);
53 $TimeTag = $Date*10 + 1; $Kp{$TimeTag} = $a;
54 $TimeTag = $Date*10 + 2; $Kp{$TimeTag} = $b;
55 $TimeTag = $Date*10 + 3; $Kp{$TimeTag} = $c;
56 $TimeTag = $Date*10 + 4; $Kp{$TimeTag} = $d;
57 $TimeTag = $Date*10 + 5; $Kp{$TimeTag} = $e;
58 $TimeTag = $Date*10 + 6; $Kp{$TimeTag} = $f;
59 $TimeTag = $Date*10 + 7; $Kp{$TimeTag} = $g;
60 $TimeTag = $Date*10 + 8; $Kp{$TimeTag} = $h;
69 # Add in very latest stuff
71 $grabcmd = "cd /tmp; wget --passive-ftp --tries 2 -q ftp://ftp.swpc.noaa.gov/pub/latest/curind.txt";
73 %lmonstr = ( "Jan", 1, "Feb", 2, "Mar", 3, "Apr", 4, "May", 5, "Jun", 6, "Jul", 7, "Aug", 8, "Sep", 9, "Oct", 10, "Nov", 11, "Dec", 12);
75 @lval = ($lyear, $lmonstr{$lmon}, $ldom);
76 open(TmpFile
, "/tmp/curind.txt");
79 if ($_ =~ /^:Geomagnetic_Values: (\d{4}) (.*) (\d{1,2})/){
84 $y =~ s/^:Geomagnetic_Values: (\d{4}) (.*) (\d{1,2})/\1/;
85 $ms =~ s/^:Geomagnetic_Values: (\d{4}) (.*) (\d{1,2})/\2/;
86 $d =~ s/^:Geomagnetic_Values: (\d{4}) (.*) (\d{1,2})/\3/;
87 $tDate = $y*10000 + $lmonstr{$ms}*100 + $d;
93 if ($_ =~ /^\s{1,}[0-9e\.\+\-]{2,}\s{1,}[0-9e\.\+\-]{2,}\s{1,}[0-9e\.\+\-]{2,}\s{1,}[0-9e\.\+\-]{2,}\s{1,}[0-9e\.\+\-]{2,}\s{1,}[ABCMX]{1,}[0-9\.]{1,}\s{1,}[0-9-]{1,}/){
103 $Line =~ s/.*\s{3,}(.*)/\1/;
104 ($a, $b, $c, $d, $e, $f, $g, $h) = split(/\s{1,}/, $Line);
106 $TimeTag = $tDate*10 + 1; $Kp{$TimeTag} = $a;
107 $TimeTag = $tDate*10 + 2; $Kp{$TimeTag} = $b;
108 $TimeTag = $tDate*10 + 3; $Kp{$TimeTag} = $c;
109 $TimeTag = $tDate*10 + 4; $Kp{$TimeTag} = $d;
110 $TimeTag = $tDate*10 + 5; $Kp{$TimeTag} = $e;
111 $TimeTag = $tDate*10 + 6; $Kp{$TimeTag} = $f;
112 $TimeTag = $tDate*10 + 7; $Kp{$TimeTag} = $g;
113 $TimeTag = $tDate*10 + 8; $Kp{$TimeTag} = $h;
115 $Kp{190001011} = 999;
116 $Kp{190001012} = 999;
117 $Kp{190001013} = 999;
118 $Kp{190001014} = 999;
119 $Kp{190001015} = 999;
120 $Kp{190001016} = 999;
121 $Kp{190001017} = 999;
122 $Kp{190001018} = 999;
129 foreach $key (reverse sort keys %Kp ) {
130 if (($Kp{$key} >= 0)&&($n < 8)){
131 $Result{$key} = $Kp{$key};
136 open(TmpFile
, ">/tmp/LatestKp.txt");
137 foreach $key (sort keys %Result ) {
138 if ($Result{$key} > 10) { $Result{$key} = -1; }
139 printf TmpFile
"$key $Result{$key}\n";
145 $FluxLine =~ s/^\s*//;
146 if ($FluxLine =~ /\d/){
147 ($E1, $E2, $P1, $P2, $P3, $Xray, $junk) = split(/\s{1,}/, $FluxLine);
159 printf TmpFile
"$E1\n";
160 printf TmpFile
"$E2\n";
161 printf TmpFile
"$P1\n";
162 printf TmpFile
"$P2\n";
163 printf TmpFile
"$P3\n";
164 printf TmpFile
"$Xray\n";
177 # $Gif = "$List[$#List]";
178 # $Latest = "http://swdcdb.kugi.kyoto-u.ac.jp/dstdir/dst1/q/$Gif";
181 # $grabcmd = "/u/mgh/wwwgrab/wwwgrab $Latest /n/tmp/polar/$Gif";
185 # system "convert -crop 0x0 /n/tmp/polar/${Gif} /n/tmp/polar/Dst.rle";
186 # system "fant -s .5 .5 -o /n/tmp/polar/Dst2.rle /n/tmp/polar/Dst.rle";
187 # system "convert -frame 4x4 -gamma 3 -crop 0x0 -colors 256 /n/tmp/polar/Dst2.rle /n/leadbelly/belly3/PolarNRT/CEPPAD/IPS/LatestDst.gif";
193 # open(TmpFile, ">/n/leadbelly/belly3/PolarNRT/CEPPAD/IPS/LatestDst.txt");
194 # printf TmpFile "${Gif}\n";
197 # system "touch /n/leadbelly/belly3/PolarNRT/CEPPAD/IPS/LatestDst.txt";
202 local($ldate_string, $ldow, $lmon, $ldom, $ltim, $lyear, %lmonstr, $tzone, @lval);
204 $ldate_string = &ctime
(time);
205 ($ldow, $lmon, $ldom, $ltim, $lyear) = split(" ", $ldate_string);
207 %lmonstr = ( "Jan", 1, "Feb", 2, "Mar", 3, "Apr", 4, "May", 5, "Jun", 6, "Jul", 7, "Aug", 8, "Sep", 9, "Oct", 10, "Nov", 11, "Dec", 12);
209 @lval = ($lyear, $lmonstr{$lmon}, $ldom);