From 25424d3c33e9b7641dab72d447668de61a4064c9 Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Wed, 23 Jun 2021 10:54:51 -0500
Subject: [PATCH] minor

---
 modules/aeolus/aeolus_amv.py | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/modules/aeolus/aeolus_amv.py b/modules/aeolus/aeolus_amv.py
index b1133273..e985b5f2 100644
--- a/modules/aeolus/aeolus_amv.py
+++ b/modules/aeolus/aeolus_amv.py
@@ -1929,7 +1929,7 @@ def create_file(filename, aeolus_to_amv_dct, aeolus_dct, amv_files, cld_lyr=Fals
 
     rootgrp.close()
 
-def create_file_new(match_dct, filename, clvrx_params):
+def create_file_new(match_dct, filename, amv_params):
     grd_x_len = 9
     grd_y_len = 9
     num_aparams = 7
@@ -1974,13 +1974,14 @@ def create_file_new(match_dct, filename, clvrx_params):
     lines = np.array(lines)
 
     # Sample file to retrieve and copy variable attributes
-    rg_exmpl = Dataset('/home/rink/data/clavrx/clavrx_OR_ABI-L1b-RadF-M6C01_G16_s20192930000343.level2.nc', 'r')
+    rg_exmpl = Dataset('/ships19/cloud/scratch/4TH_AMV_INTERCOMPARISON/FMWK2_AMV/GOES16_ABI_2KM_FD_2019293_0020_34_WINDS_AMV_EN-14CT.nc', 'r')
 
     # the top level group for the output file
     rootgrp = Dataset(filename, 'w', format='NETCDF4')
 
-    dim_amvs = rootgrp.createDimension('num_aeolus_params', size=num_aparams)
+    dim_aparams = rootgrp.createDimension('num_aeolus_params', size=num_aparams)
     dim_alevs = rootgrp.createDimension('max_num_aeolus_levels', size=max_num_alevels)
+    dim_amvs = rootgrp.createDimension('max_num_amvs', size=max_num_amvs)
     dim_num_aeolus_prof = rootgrp.createDimension('num_aeolus_profs', size=num_aprofs)
     dim_grd_x = rootgrp.createDimension('grd_x_len', size=grd_x_len)
     dim_grd_y = rootgrp.createDimension('grd_y_len', size=grd_y_len)
@@ -2007,13 +2008,13 @@ def create_file_new(match_dct, filename, clvrx_params):
     # ----- Product variables ----------------
     nc4_vars = []
     var_s = rg_exmpl.variables
-    for pidx, param in enumerate(clvrx_params):
+    for pidx, param in enumerate(amv_params):
         v = var_s[param]
         attr_s = v.ncattrs()
         if '_FillValue' in attr_s:
-            var = rootgrp.createVariable(param, v.dtype, ['num_aeolus_profs', 'grd_y_len', 'grd_x_len'], fill_value=v.getncattr('_FillValue'))
+            var = rootgrp.createVariable(param, v.dtype, ['num_aeolus_profs', 'max_num_amvs'], fill_value=v.getncattr('_FillValue'))
         else:
-            var = rootgrp.createVariable(param, v.dtype, ['num_aeolus_profs', 'grd_y_len', 'grd_x_len'])
+            var = rootgrp.createVariable(param, v.dtype, ['num_aeolus_profs', 'max_num_amvs'])
         # copy attributes from example to new output variable of the same name
         for attr in attr_s:
             if attr != '_FillValue':
@@ -2041,8 +2042,8 @@ def create_file_new(match_dct, filename, clvrx_params):
                 prf_hht[idx,k] = prof[k,3]
                 prf_hhb[idx,k] = prof[k,4]
 
-            for pidx, param in enumerate(clvrx_params):
-                nc4_vars[pidx][idx, :, :] = param_nd[pidx, :, :]
+            for pidx, param in enumerate(amv_params):
+                nc4_vars[pidx][idx, :] = param_nd[pidx, :]
             idx += 1
 
     rg_exmpl.close()
@@ -2068,7 +2069,7 @@ def create_amv_to_aeolus_match_file(aeolus_files_dir, amv_files_dir, outfile=Non
     m_d = match_amvs_to_aeolus_fast(a_d, amv_files_dir, amv_source, band, amv_files)
 
     if outfile is not None:
-        create_file(outfile, m_d, a_d, amv_files)
+        create_file_new(outfile, m_d, amv_files)
 
 
 # match_file: pathname for the product file
-- 
GitLab