-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsfcdewp.php
140 lines (120 loc) · 3.52 KB
/
sfcdewp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/php
<?php
# Load required settings & functions:
require ("/home/scripts/models/prodscripts/settings.php");
# Directory containing all the product script sub-directories, defined in settings.php:
$ProdDir = ProdDir();
# Current working directory, set this to where our color table is...
# Be aware, this is also where the image will be created:
$cwd = "$ProdDir/dewpoint";
# Define the level and product to be generated (for use in filenames):
$Level = "sfc";
$Product = "dewp";
# Handle the incoming vars:
# Ordering is Model Runtime, Model Name, Forecast Hour, Sector.
$ModRunTime = $argv[1];
$Model = $argv[2];
$FHour = $argv[3];
$Sector = $argv[4];
# Set the size of the image:
$Size = SetImageSize($Sector,$DefaultImageSize);
# Load Sector Coords and projections:
$SectorArr = SetSectorInfo($Sector);
$Domain = $SectorArr["Domain"];
$Projection = $SectorArr["Projection"];
# Convert model name to grid name, and return a "clean" model name:
$ModArr = SetModGridNames($Model);
$ModName = $ModArr["ModName"];
$GridName = $ModArr["GridName"];
# Make lowercase modname, used for image filename:
$LModName = strtolower($ModName);
# Set Base Directory and Image File Name:
$BaseDir = BaseDir();
$SubDir = SubDir($ModName,$ModRunTime,$Sector);
$ImageFileName = $LModName.$Sector."_".$Level."_".$Product."_".$FHour.".gif";
# Get the file name for the date string (file will be created by running this script):
$TextFileName = DateLabelFile($ModRunTime, $ModName, $FHour, $Level, $Product, $Sector, $cwd);
if (in_array($Sector, $BigSectors)) {
$Mapfil = "base";
$Map = "32//1";
} else {
$Mapfil = "rdis + base";
$Map = "28//1 + 32//1";
}
$stnplt = SetStationPlt($Product, $Sector);
$LI = SetLI($ModName);
$IJSkip = SetIJSkip($GridName, $Sector);
# Gempak magic, the parms we will send to the program:
$parms = "
\$mapfil = $Mapfil
GDFILE = $GridName | $ModRunTime
GDATTIM = f$FHour
GLEVEL = 2
GVCORD = hght
PANEL = 0
SKIP = 0
SCALE = 0
GDPFUN = DWPF!DWPF!DWPF!$LI!$LI
TYPE = FC!C!C!C!C
CONTUR = 0!0!1/1!1/1!1/1
CINT = 0;5;10;15;20;25;30;35;40;45;50;55;60;65;70;75;80;85;90;95;100!5/-30/-5!1/45/45!1/-30/-1!1/1/50
LINE = 32/10/1!23/1/1!31/1/1/n!26/1/1!27/1/1/n
FINT = 0;5;10;15;20;25;30;35;40;45;50;55;60;65;70;75;80
FLINE = 31;1;2;3;4;5;6;7;8;9;10;11;12;14;15;16;17;18
HILO =
HLSYM =
CLRBAR = 31/h/lc/.5;.002/.95;.012//|.65/1
WIND = ak6/.6//111/.4
REFVEC =
TITLE = 31/-3/2m DEWPOINT (F) / LIFTED INDEX (C) - COD NEXLAB WEATHER.COD.EDU
TEXT = 1/1/hw
CLEAR = y
GAREA = $Domain
PROJ = $Projection
MAP = $Map
LATLON =
IJSKIP = $IJSkip
DEVICE = GIF|$ImageFileName|$Size
STNPLT = $stnplt
SATFIL =
RADFIL =
IMCBAR =
FILTER = 1.1
STREAM = 1/0.8
BOXLIN = 32
REGION = view
TXTCOL = 31
TXTYPE = 1/2//221/s/c/sw
TXTFIL = $TextFileName
TXTLOC = .8;1
COLUMN =
SHAPE =
INFO =
LOCI =
ANOTLN =
ANOTYP =
r
exit
";
# Here we go, run the program and send it parms:
$p = proc_open("gdplot3_gf", $desc, $pipes, $cwd);
fwrite($pipes[0], $parms);
# Catch program output, and print to screen (or where-ever):
if ($PrintOutput) {
$return = stream_get_contents($pipes[1]);
print_r($return);
}
// all done! Clean up
fclose($pipes[1]);
#fclose($pipes[2]);
proc_close($p);
#For now, move image from cwd to pwd TESTING PURPOSES ONLY!:
#$pwd = getcwd();
$FullPath = $BaseDir.$SubDir;
EnsureDirExists($FullPath);
rename("$cwd/$ImageFileName", $FullPath."/".$ImageFileName);
# For production, have unlink commands here to delete temp files.
unlink($TextFileName);
unlink($cwd."/gemglb.nts");
unlink($cwd."/last.nts");
?>