-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
edd00d9
commit 527fdfb
Showing
7 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// this file must use UNIX Style End of Line | ||
defdim("lev", 1, 1); | ||
lev[$lev] = 1.0; | ||
lev@long_name = "Level"; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
$GISIntervalsPath = $env:My_GIS_Internals_Path | ||
. $GISIntervalsPath\SDKShell.ps1 "setenv" | ||
|
||
Add-Type -AssemblyName Microsoft.VisualBasic | ||
function Remove-TempFile($filePath) { | ||
Get-ChildItem -Path $filePath -Filter "tempFile*" | ForEach-Object { | ||
$fileName = $_.name | ||
[Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile("$filePath\$fileName ", 'OnlyErrorDialogs', 'SendToRecycleBin') | ||
} | ||
} | ||
|
||
$filePath = "C:\Users\Rayman\Downloads" | ||
$dataDate = "20180916" | ||
|
||
$scaleVariableArray = | ||
"Precipitable_water_entire_atmosphere_single_layer", | ||
"Pressure_surface", | ||
"Temperature_surface", | ||
"Wind_speed_gust_surface" | ||
|
||
for ($i = 0; $i -lt $scaleVariableArray.Length; $i++) { | ||
$variableName = $scaleVariableArray[$i] | ||
$outputFile = "$filePath\${variableName}_$dataDate.tif" | ||
& "gdal_translate.exe" -of "GTiff" -ot "Byte" NETCDF:"$filePath\scaled.nc":$variableName "$filePath\tempFile_$variableName.tif" | ||
& "gdalwarp.exe" -t_srs "WGS84" -wo SOURCE_EXTRA=1000 --config CENTER_LONG 0 "$filePath\tempFile_$variableName.tif" "$outputFile" | ||
} | ||
Remove-TempFile $filePath |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// this file must use UNIX Style End of Line | ||
U@min = U.min(); | ||
U@max = U.max(); | ||
V@min = V.min(); | ||
V@max = V.max(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Set the install path of NetCDF Operators | ||
$NCOPath = "path\to\NetCDFOperators" | ||
$ncap2 = "$NCOPath\ncap2.exe" | ||
$ncecat = "$NCOPath\ncecat.exe" | ||
$ncks = "$NCOPath\ncks.exe" | ||
$ncpdq = "$NCOPath\ncpdq.exe" | ||
$ncrename = "$NCOPath\ncrename.exe" | ||
|
||
# Set the absolute path of the NetCDF file you want to process | ||
$fileToProcess = "path\to\file.nc" | ||
|
||
Add-Type -AssemblyName Microsoft.VisualBasic | ||
function Remove-TempNCFile($fileDirectory) { | ||
Get-ChildItem -Path $fileDirectory -Filter "temp*.nc" | ForEach-Object { | ||
$fileName = $_.name | ||
[Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile("$fileDirectory\$fileName", 'OnlyErrorDialogs', 'SendToRecycleBin') | ||
} | ||
} | ||
|
||
function Main { | ||
$fileDirectory = Split-Path $fileToProcess -Parent | ||
|
||
$scalarVariableArray = | ||
"Precipitable_water_entire_atmosphere_single_layer", | ||
"Pressure_surface", | ||
"Temperature_surface", | ||
"Wind_speed_gust_surface" | ||
|
||
$scalarVariables = $scalarVariableArray -join ',' | ||
& $ncks -v "$scalarVariables" "$fileToProcess" "$fileDirectory\tempScalar.nc" | ||
& $ncap2 -3 -S "scale.nco" "$fileDirectory\tempScalar.nc" "$fileDirectory\scaled.nc" | ||
|
||
$uWind = "u-component_of_wind_planetary_boundary" | ||
$vWind = "v-component_of_wind_planetary_boundary" | ||
$windVariableArray = $uWind, $vWind | ||
|
||
$windVariable = $windVariableArray -join ',' | ||
& $ncks -v "$windVariable" "$fileToProcess" "$fileDirectory\tempWind.nc" | ||
& $ncrename -v "$uWind,U" -v "$vWind,V" "$fileDirectory\tempWind.nc" "$fileDirectory\tempUV.nc" | ||
& $ncap2 -S "defineLev.nco" "$fileDirectory\tempUV.nc" "$fileDirectory\tempLevDim.nc" | ||
& $ncecat -u "lev" "$fileDirectory\tempLevDim.nc" "$fileDirectory\tempRecDim.nc" | ||
& $ncks --no_rec_dmn "lev" "$fileDirectory\tempRecDim.nc" "$fileDirectory\tempFixDim.nc" | ||
& $ncpdq -a "-lat" "$fileDirectory\tempFixDim.nc" "$fileDirectory\tempInvDim.nc" | ||
& $ncap2 -3 -S "getMinMax.nco" "$fileDirectory\tempInvDim.nc" "$fileDirectory\uv.nc" | ||
Remove-TempNCFile $fileDirectory | ||
} | ||
|
||
Main |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// this file must use UNIX Style End of Line | ||
*minimum = Wind_speed_gust_surface.min(); | ||
*maximum = Wind_speed_gust_surface.max(); | ||
Wind_speed_gust_surface = (Wind_speed_gust_surface - minimum) / (maximum - minimum) * 255.0; | ||
|
||
minimum = Temperature_surface.min(); | ||
maximum = Temperature_surface.max(); | ||
Temperature_surface = (Temperature_surface - minimum) / (maximum - minimum) * 255.0; | ||
|
||
minimum = Pressure_surface.min(); | ||
maximum = Pressure_surface.max(); | ||
Pressure_surface = (Pressure_surface - minimum) / (maximum - minimum) * 255.0; | ||
|
||
minimum = Precipitable_water_entire_atmosphere_single_layer.min(); | ||
maximum = Precipitable_water_entire_atmosphere_single_layer.max(); | ||
Precipitable_water_entire_atmosphere_single_layer = (Precipitable_water_entire_atmosphere_single_layer - minimum) / (maximum - minimum) * 255.0; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ColorMap> | ||
<ColorMapEntry color="#040ED8" quantity="0" /> | ||
<ColorMapEntry color="#2050FF" quantity="17" /> | ||
<ColorMapEntry color="#4196FF" quantity="34" /> | ||
<ColorMapEntry color="#6DC1FF" quantity="51" /> | ||
<ColorMapEntry color="#86D9FF" quantity="68" /> | ||
<ColorMapEntry color="#9CEEFF" quantity="85" /> | ||
<ColorMapEntry color="#AFF5FF" quantity="102" /> | ||
<ColorMapEntry color="#CEFFFF" quantity="119" /> | ||
<ColorMapEntry color="#FFFE47" quantity="136" /> | ||
<ColorMapEntry color="#FFEB00" quantity="153" /> | ||
<ColorMapEntry color="#FFC400" quantity="170" /> | ||
<ColorMapEntry color="#FF9000" quantity="187" /> | ||
<ColorMapEntry color="#FF4800" quantity="204" /> | ||
<ColorMapEntry color="#FF0000" quantity="221" /> | ||
<ColorMapEntry color="#D50000" quantity="238" /> | ||
<ColorMapEntry color="#9E0000" quantity="255" /> | ||
</ColorMap> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
$colorArray = | ||
"#040ED8", | ||
"#2050FF", | ||
"#4196FF", | ||
"#6DC1FF", | ||
"#86D9FF", | ||
"#9CEEFF", | ||
"#AFF5FF", | ||
"#CEFFFF", | ||
"#FFFE47", | ||
"#FFEB00", | ||
"#FFC400", | ||
"#FF9000", | ||
"#FF4800", | ||
"#FF0000", | ||
"#D50000", | ||
"#9E0000" | ||
|
||
$start = 0 | ||
$end = 255 | ||
$divide = $colorArray.Length | ||
|
||
$interval = ($end - $start) / ($divide - 1) | ||
$quantity = $start | ||
$quantityArray = @() | ||
for ($i = 0; $i -le $divide; $i++) { | ||
$quantityArray += $quantity | ||
$quantity = $quantity + $interval | ||
} | ||
|
||
$xmlsettings = New-Object System.Xml.XmlWriterSettings | ||
$xmlsettings.Indent = $true | ||
$xmlsettings.IndentChars = " " | ||
$XmlWriter = [System.XML.XmlWriter]::Create("./Util/style.xml", $xmlsettings) | ||
|
||
$xmlWriter.WriteStartElement("ColorMap") | ||
for ($i = 0; $i -lt $colorArray.Length; $i++) { | ||
$xmlWriter.WriteStartElement("ColorMapEntry") | ||
$xmlWriter.WriteAttributeString("color", $colorArray[$i]) | ||
$xmlWriter.WriteAttributeString("quantity", $quantityArray[$i]) | ||
$xmlWriter.WriteEndElement() | ||
} | ||
$xmlWriter.WriteEndElement() | ||
|
||
$xmlWriter.Flush() | ||
$xmlWriter.Close() |