Skip to content

Commit 2f9c6dc

Browse files
Merge pull request #26 from GEOS-ESM/develop
add setup_gaas_obs.pl from GMAO_Etc
2 parents dcd47ae + f5b5ee1 commit 2f9c6dc

3 files changed

Lines changed: 116 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77

88
### Changed
99

10+
1011
## [v1.5.0] 2026-01-22
1112
### Changed
1213

1314
- Minor changes to get VIIRS to work in ADAS v5.43x
15+
- Move setup_gaas_obs.pl from GMAO_Etc here for consistency
16+
- chmod +x pl script
1417

1518
## [v1.4.0] 2025-12-03
1619

src/Applications/GAAS_App/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ install(
99
DESTINATION lib/Python
1010
)
1111

12-
file(GLOB pcf_files *.pcf)
12+
file(GLOB perl_files CONFIGURE_DEPENDS *.pl)
13+
file(GLOB pcf_files CONFIGURE_DEPENDS *.pcf)
1314

1415
install (
1516
FILES ${pcf_files}
1617
DESTINATION etc
1718
)
1819

20+
install (
21+
PROGRAMS ${perl_files}
22+
DESTINATION bin
23+
)
24+
1925
### MODIS
2026
set(pythonscripts modis/modis_l2a.py modis/mxd04_l2a.py)
2127
install(PROGRAMS ${pythonscripts} DESTINATION bin)
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/usr/bin/env perl
2+
#=======================================================================
3+
# name - setup_gaas_obs
4+
# purpose - organize GAAS observation data into subdirectories expected
5+
# by the reading program
6+
#
7+
# runtime parameter
8+
# => $workdir: directory location of modis data
9+
#
10+
# runtime flags (choose at least one)
11+
# => $avhrr: organize avhrr patmosx data into subdirectories
12+
# => $modis: organize modis Level2 HDF data into subdirectories
13+
#=======================================================================
14+
use strict;
15+
use warnings;
16+
17+
# global variables
18+
#-----------------
19+
my ($workdir, $modis, $viirs, $avhrr, %flags, $verbose);
20+
21+
# main program
22+
#-------------
23+
{
24+
use File::Basename ("basename");
25+
use File::Copy ("move");
26+
use File::Path ("mkpath");
27+
28+
my ($file, $base, $adflg);
29+
my ($label, $Adate, $time, $version);
30+
my ($type, $jdoy, $subdir);
31+
my ($year, $month, $day);
32+
33+
init();
34+
if ($modis) {
35+
foreach $file (<$workdir/M?D04_L2.*.*.hdf>) {
36+
$base = basename $file;
37+
($label, $Adate, $time, $version) = split /[\.]/, $base;
38+
39+
$type = substr($label, 0, 5);
40+
$year = substr($Adate, 1, 4);
41+
$jdoy = substr($Adate, 5, 3);
42+
43+
$subdir = "$workdir/$version/$type/$year/$jdoy";
44+
unless (-d $subdir) {
45+
mkpath($subdir, \%flags) or die "Error making dir: $subdir;";
46+
system("touch $subdir/.no_archiving");
47+
}
48+
print "mv $file $subdir\n" if $verbose;
49+
move($file, $subdir);
50+
}
51+
}
52+
53+
if ($avhrr) {
54+
foreach $file (<$workdir/patmosx_v05r02.*.npz>) {
55+
$base = basename $file;
56+
($label, $adflg, $Adate) = split /[\.]/, $base;
57+
58+
$year = substr($Adate, 0, 4);
59+
$month = substr($Adate, 4, 2);
60+
$day = substr($Adate, 6, 2);
61+
62+
$subdir = "$workdir/Y$year/M$month/D$day";
63+
unless (-d $subdir) {
64+
mkpath($subdir, \%flags) or die "Error making dir: $subdir;";
65+
system("touch $subdir/.no_archiving");
66+
}
67+
print "mv $file $subdir\n" if $verbose;
68+
move($file, $subdir);
69+
}
70+
}
71+
72+
if ($viirs) {
73+
foreach $file (<$workdir/VN20AERD?_L2_VIIRS_NOAA20.*.*.nc>) {
74+
$base = basename $file;
75+
($label, $Adate, $time, $version) = split /[\.]/, $base;
76+
77+
$type = substr($label, 0, 9);
78+
$year = substr($Adate, 1, 4);
79+
$jdoy = substr($Adate, 5, 3);
80+
81+
$subdir = "$workdir/${type}/$version/$year/$jdoy";
82+
unless (-d $subdir) {
83+
mkpath($subdir, \%flags) or die "Error making dir: $subdir;";
84+
system("touch $subdir/.no_archiving");
85+
}
86+
print "mv $file $subdir\n" if $verbose;
87+
move($file, $subdir);
88+
}
89+
}
90+
}
91+
92+
#=======================================================================
93+
# name - init
94+
# purpose - get input parameters and flags
95+
#=======================================================================
96+
sub init {
97+
use Getopt::Long;
98+
99+
GetOptions( "v" => \$verbose,
100+
"viirs" => \$viirs,
101+
"modis" => \$modis,
102+
"avhrr" => \$avhrr );
103+
$workdir = shift @ARGV;
104+
105+
$flags{"verbose"} = 1 if $verbose;
106+
}

0 commit comments

Comments
 (0)