Skip to content

Level 4

Peter Isaac edited this page Oct 12, 2021 · 3 revisions

Level 4 - Gap filling of meteorology

  1. Read the Level 3 netCDF4 file; make a copy of the L3 data - ds4 = pfp_io.copy_datastructure(cf, ds3)
    1. ds4 will be empty (logical false) if an error occurs in copy_datastructure, return from this routine if this is the case (if not ds4: return ds4)
  2. Set some attributes for this level - pfp_utils.UpdateGlobalAttributes(cf, ds4, "L4")
  3. Check to see if we have any imports - pfp_gf.ImportSeries(cf, ds4)
  4. Re-apply the quality control checks (range, diurnal and rules) - pfp_ck.do_qcchecks(cf, ds4)
  5. Now do the meteorological driver gap filling, parse the control file for information on how the user wants to do the gap filling - l4_info = pfp_gf.ParseL4ControlFile(cf, ds4)
  6. Start of the section that does the gap filling of the drivers - read the alternate data files - ds_alt = pfp_gf.ReadAlternateFiles(ds4, l4_info)
    1. Fill short gaps using interpolation - pfp_gf.GapFillUsingInterpolation(cf, ds4)
    2. Gap fill using climatology if "GapFillFromClimatology" in l4_info: pfp_gf.GapFillFromClimatology(ds4, l4_info, "GapFillFromClimatology")
    3. Do the gap filling using the ACCESS, AWS and ERA5 output: The alternate data gap fill GUI is displayed separately from the main PyFluxPro GUI. It consists of text to display the start and end datetime of the file, two entry boxes for the start and end datetimes of the alternate data gap fill and a button to insert the gap fill data ("Run") and a button to exit ("Done") the GUI when we are done. On exit, the PyFluxPro main GUI continues and eventually writes the gap filled data to file. pfp_gfALT.GapFillFromAlternate(main_gui, ds4, ds_alt, l4_info, "GapFillFromAlternate")
    4. Merge the first group of gap filled drivers into a single series - pfp_ts.MergeSeriesUsingDict(ds4, l4_info, merge_order="prerequisite")
  7. Re-calculate the ground heat flux but only if requested in control file
    1. opt = pfp_utils.get_keyvaluefromcf(cf,["Options"], "CorrectFgForStorage", default="No", mode="quiet")
    2. If re-calculate - pfp_ts.CorrectFgForStorage(cf, ds4, Fg_out='Fg', Fg_in='Fg_Av', Ts_in='Ts', Sws_in='Sws')
  8. Re-calculate the net radiation - pfp_ts.CalculateNetRadiation(cf, ds4, Fn_out='Fn', Fsd_in='Fsd', Fsu_in='Fsu', Fld_in='Fld', Flu_in='Flu')
  9. Re-calculate the available energy - pfp_ts.CalculateAvailableEnergy(ds4, Fa_out='Fa', Fn_in='Fn', Fg_in='Fg')
  10. Merge the second group of gap filled drivers into a single series - pfp_ts.MergeSeriesUsingDict(ds4, l4_info, merge_order="standard")
  11. Re-calculate the water vapour concentrations - pfp_ts.CalculateHumiditiesAfterGapFill(ds4, l4_info)
  12. Re-calculate the meteorological variables - pfp_ts.CalculateMeteorologicalVariables(ds4, l4_info)
  13. Data stats and clean up
    1. Check for any missing data - pfp_utils.get_missingingapfilledseries(ds4, l4_info)
    2. Write the percentage of good data as a variable attribute - pfp_utils.get_coverage_individual(ds4)
    3. Write the percentage of good data for groups - pfp_utils.get_coverage_groups(ds4)
    4. Remove intermediate series from the data structure - pfp_ts.RemoveIntermediateSeries(ds4, l4_info)

Clone this wiki locally