Skip to content

Commit

Permalink
Merge pull request #246 from GEOS-ESM/feature/saraqzhang/fstats2mQT
Browse files Browse the repository at this point in the history
        add fstats customized for screen-level Q and T with "land only" option
  • Loading branch information
sdrabenh authored May 3, 2022
2 parents 237d09b + 7b1f1e0 commit fcec98b
Show file tree
Hide file tree
Showing 5 changed files with 358 additions and 17 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added statsNx.rc for screen level variable fstats
### Changed

- Added options for land-only and screen-level variables in fstats.x and g5fcst_stats.pl

## [Unreleased]

### Added

### Changed

- Added a few new tags to `regrid.pl`
Expand Down
3 changes: 2 additions & 1 deletion GEOS_Util/post/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ set (post_rc
plot.rc
post.rc
stats.rc
statsNx.rc
time_ave.rc
3CH.rc
)
Expand All @@ -151,7 +152,7 @@ install (
)

install (
FILES stats.rc time_ave.rc
FILES stats.rc time_ave.rc statsNx.rc
DESTINATION etc
)

Expand Down
110 changes: 95 additions & 15 deletions GEOS_Util/post/g5fcst_stats.pl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
#=======================================================================
# name - g5fcst_stats.pl
# name - g5fcst_stats.pl
# purpose - script to submit jobs to calculate forecast statistics
#
# key global variables -
Expand Down Expand Up @@ -29,7 +29,11 @@
my ($offset_sec, $pesto, $progdir, $progtype, $secs_per_day, $secs_per_hour);
my ($statsX, $storedir, $tau_freq, $tau_fsec, $vanadir, $vanatype, $vexpid);
my (%opts, @acqIDs, @statsIDs);
my ($landonly, $landonly_dflt);
my ($nxonly, $nxonly_dflt);

$landonly_dflt = "no";
$nxonly_dflt = "no" ;
$fhours_dflt = 123;
$localID = $$;
$ncsuffix = ".nc4";
Expand Down Expand Up @@ -135,7 +139,11 @@

if ($ihh eq "00" and $nv == 1) {
$fdir = "$vanadir/Y$nyyyy/M$nmm";
$fname = "$vexpid.$vanatype.inst3d_met_p.${vdate}_${vhh}${vmn}z";
if ($nxonly eq "yes") {
$fname = "$vexpid.$vanatype.${vdate}_${vhh}${vmn}z";
} else {
$fname = "$vexpid.$vanatype.inst3d_met_p.${vdate}_${vhh}${vmn}z";
}
$ffile0 = "$fdir/$fname$ncsuffix";
}
else {
Expand Down Expand Up @@ -167,7 +175,11 @@
push @alist, "$vexpid.$vanatype.${vdate}_${vhh}z+${vdate}_${vhh}${vmn}z";
}
else {
push @alist, "$vexpid.$vanatype.inst3d_met_p.${vdate}_${vhh}${vmn}z";
if ($nxonly eq "yes" ) {
push @alist, "$vexpid.$vanatype.${vdate}_${vhh}${vmn}z";
} else {
push @alist, "$vexpid.$vanatype.inst3d_met_p.${vdate}_${vhh}${vmn}z";
}
}

# loop through naming convention options
Expand All @@ -192,9 +204,12 @@
#----------------------------------------------------
($vdate, $vtime) = tick($vdate, $vtime, $tau_fsec);
}

if ($nxonly eq "yes") {
@climfiles = (<$ENV{SHARE}/dao_ops/verification/stats/MERRA-2.inst1_2d_asm_Nx.198501_201412.clim_??z.576x361.data.nc4>);
} else {
@climfiles = (<$ENV{SHARE}/dao_ops/verification/stats/MERRA-2.inst3_3d_asm_Np.198501_201412.clim_??z.576x361.data.nc4>);
#--@climfiles = (<$ENV{SHARE}/dao_ops/verification/stats/merrasc.197901-200812.clim_??z.144x91.data.nc>);
}
$climfilecnt = scalar(@climfiles);
if ($climfilecnt < 4) {
rmtree($fstatswork) if -d $fstatswork;
Expand All @@ -221,15 +236,23 @@
}
else {
push @fcst_fnames, $ffile0 if $ffile0;
push @fcst_fnames, "$expid.prog.$progtype.${ndate}_${ihh}z+*$ncsuffix";
push @ana_fnames, "$vexpid.asm.inst3d_met_p.*$ncsuffix";
push @fcst_fnames, "$expid.prog.$progtype.${ndate}_${ihh}z+*$ncsuffix";
if ($nxonly eq "yes" ) {
push @ana_fnames, "$vexpid.$vanatype.*$ncsuffix";
} else {
push @ana_fnames, "$vexpid.asm.inst3d_met_p.*$ncsuffix";
}
}
}
else {
push @fcst_fnames, $ffile0 if $ffile0;
push @fcst_fnames, "$expid.prog.$progtype.${ndate}_${ihh}z+*$ncsuffix";
push @ana_fnames, "$vexpid.asm.inst3d_met_p.*$ncsuffix";
push @ana_fnames, "$vexpid.ana.inst3d_met_p.*$ncsuffix";
if ($nxonly eq "yes" ) {
push @ana_fnames, "$vexpid.$vanatype.*$ncsuffix"
} else {
push @ana_fnames, "$vexpid.asm.inst3d_met_p.*$ncsuffix";
push @ana_fnames, "$vexpid.ana.inst3d_met_p.*$ncsuffix";
}
}
@fcstlist = sort keys %fcsthash;
@vanalist = sort keys %vanahash;
Expand Down Expand Up @@ -282,6 +305,8 @@
$args{"vhh0"} = $vhh0;
$args{"vhh1"} = $vhh1;
$args{"nodes"} = $nodes;
$args{"landonly"} = $landonly;
$args{"nxonly"} = $nxonly;

# submit job to calculate stats
#------------------------------
Expand Down Expand Up @@ -344,6 +369,10 @@ sub init {

"nodes=s" => \$nodes,

"landonly=s" => \$landonly,

"nxonly=s" => \$nxonly,

"das" => \$dasFLG,
"np" => \$noprompt,

Expand All @@ -359,7 +388,15 @@ sub init {
$expid = shift @ARGV;
$idate = shift @ARGV;
$ndays = shift @ARGV;


# landonly option
#----------------
$landonly = $landonly_dflt unless $landonly;

#nxonly option
#--------------
$nxonly = $nxonly_dflt unless $nxonly;

# initial fcst hour and offset
#-----------------------------
unless ($ihh) {
Expand Down Expand Up @@ -536,9 +573,12 @@ sub init {
# find stats.rc
#--------------
$fv_etcdir = dirname($Bin) ."/etc";
die "Error. Cannot find $fv_etcdir/stats.rc" unless -e "$fv_etcdir/stats.rc";
if ($nxonly eq "yes" ) {
die "Error. Cannot find $fv_etcdir/statsNx.rc" unless -e "$fv_etcdir/statsNx.rc";
} else {
die "Error. Cannot find $fv_etcdir/stats.rc" unless -e "$fv_etcdir/stats.rc";
}
}

#=======================================================================
# name - das_check
# purpose - check for hidden files in $FVHOME/fcst and $FVHOME directories
Expand Down Expand Up @@ -636,11 +676,14 @@ sub submit_calcjob {
my (@rmfilelist, $yyyy, $mm, $dd);
my ($logdir, $logfile1, $logfile2, $jobname, $jobdate, $jobfile, $jobtype);
my ($cmd, $jobID, $jobIDline);
my (@levs, @levels_19, @levels_11);
my (@levs, @levels_19, @levels_11, @levels_1);
my ($mynodes,$usrnodes);
my ($qos, $partition);
my ($ntspn, $npn);

my ($landonly, $landmaskdirfile);
my ($nxonly);
my ($whichrc);

@levels_19 = ( 1000.0, 975.0, 950.0, 925.0,
900.0, 850.0, 800.0, 750.0,
700.0, 600.0, 500.0, 400.0,
Expand All @@ -651,6 +694,8 @@ sub submit_calcjob {
500.0, 400.0, 300.0, 250.0,
200.0, 150.0, 100.0 );

@levels_1 = ( 1000.0 ) ;

if ($vexpid eq "ecmwf") { @levs = @levels_11 }
else { @levs = @levels_19 }

Expand All @@ -668,6 +713,22 @@ sub submit_calcjob {
$vdate1 = $args{"vdate1"};
$vhh1 = $args{"vhh1"};
$usrnodes = $args{"nodes"};
$landonly = $args{"landonly"};
$nxonly = $args{"nxonly"};
print "nxonly: $nxonly\n";
print "landonly: $landonly\n";

if ($landonly eq "yes") {
$landmaskdirfile = "$jobdir/landmaskfile.nc4";
die "Error. Cannot find $landmaskdirfile" unless -e "$landmaskdirfile";
}

$whichrc = "stats.rc";
if ($nxonly eq "yes") {
@levs = @levels_1;
$whichrc = "statsNx.rc";
print "whichrc: $whichrc\n";
}

foreach (@fcstlist, @vanalist) { push @rmfilelist, basename($_) };

Expand Down Expand Up @@ -736,12 +797,24 @@ sub submit_calcjob {
-cli @climfiles \\
-tag $expid.${ihh}z \\
-nfreq ${tau_freq}0000 \\
EOF
if ( $landonly eq "yes" ) {
print FH <<"EOF";
-land ${landmaskdirfile} \\
EOF
}

print FH <<"EOF";
-levs @levs \\
-o $expid.fstats.log.$jobdate.txt \\
-verif gmao \\
-fcsrc gmao \\
-fhour $fhours \\
-rc $fv_etcdir/stats.rc
-rc $fv_etcdir/$whichrc
EOF

print FH <<"EOF";
@ calc_status = \$status
$pesto -arc $arcfile \\
Expand Down Expand Up @@ -940,7 +1013,8 @@ sub verify_values {
print "progdir: $progdir\n";
print "progtype: $progtype\n";
print "fs_tag: $fs_tag\n\n";

print "landonly: $landonly\n\n";
print "nxonly: $nxonly\n\n";
print "dryrun: $dryrun\n\n" if $dryrun;

$ans = query("Continue (y/n):", "y");
Expand Down Expand Up @@ -986,6 +1060,12 @@ sub usage {
[dirname(\$FVHOME) or \$NOBACKUP]
-noarchive do not archive outputs [archives by default]
-landonly calculate stats only over land surface (yes/no)
[no by default]
-nxonly calculate stats of 2d Nx collection only (yes/no)
[no by default]
-nodes nodesname specify nodes (e.g., sky, hasw, or cas)
-das check for DAS hidden files before attempting to fetch files
and set no prompt; requires \$FVHOME environment variable;
Expand Down
Loading

0 comments on commit fcec98b

Please sign in to comment.