GIS4WRF / gis4wrf

QGIS toolkit 🧰 for pre- and post-processing 🔨, visualizing 🔍, and running simulations 💻 in the Weather Research and Forecasting (WRF) model 🌀
https://gis4wrf.github.io
MIT License
159 stars 36 forks source link

KeyError 'XLONG_U' when attempting to view wrfout files. #166

Closed wrightwx closed 3 years ago

wrightwx commented 4 years ago

I am wondering what is causing the error. I am using QGIS 3.12.0-București and the latest updated giswrf plugin. I can load and view the files just fine in NOAA's WCT 4.5.0 (https://www.ncdc.noaa.gov/wct/) See Log below:

2020-03-09T12:37:22     WARNING    Traceback (most recent call last):
              File "C:/Users/wrigh/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gis4wrf\plugin\ui\widget_view.py", line 255, in on_variable_selected
              self.replace_variable_layer()
              File "C:/Users/wrigh/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gis4wrf\plugin\ui\widget_view.py", line 297, in replace_variable_layer
              dataset.path, variable.name, extra_dim_index, interp_level, interp_vert_name)
              File "C:/Users/wrigh/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gis4wrf\core\transforms\wrf_netcdf_to_gdal.py", line 140, in convert_wrf_nc_var_to_gdal_dataset
              geo_transform = get_geo_transform(ds, crs)
              File "C:/Users/wrigh/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gis4wrf\core\transforms\wrf_netcdf_to_gdal.py", line 446, in get_geo_transform
              lons_u = ds.variables['XLONG_U']
             KeyError: 'XLONG_U'
letmaik commented 3 years ago

The issue here is probably that you didn't open a WRF output file but some other file. If it indeed was a WRF output file, then an ncdump -h would shed some light on this issue.

dmey commented 3 years ago

@wrightwx did you solve the issue?

dmey commented 3 years ago

Closing as no response from user.

georgeboldeanu commented 2 years ago

Hi! I have the same Issue as @wrightwx. Here is the error from QGIS log:

2022-01-27T11:37:40 WARNING Traceback (most recent call last): File "C:/Users/george.boldeanu/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gis4wrf\plugin\ui\widget_view.py", line 255, in on_variable_selected self.replace_variable_layer() File "C:/Users/george.boldeanu/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gis4wrf\plugin\ui\widget_view.py", line 297, in replace_variable_layer dataset.path, variable.name, extra_dim_index, interp_level, interp_vert_name) File "C:/Users/george.boldeanu/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gis4wrf\core\transforms\wrf_netcdf_to_gdal.py", line 140, in convert_wrf_nc_var_to_gdal_dataset geo_transform = get_geo_transform(ds, crs) File "C:/Users/george.boldeanu/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gis4wrf\core\transforms\wrf_netcdf_to_gdal.py", line 446, in get_geo_transform lons_u = ds.variables['XLONG_U'] KeyError: 'XLONG_U'

Also as @letmaik recommend I got a ncdump info about the file:

george_regex@GB_HpWorker:/mnt/f/Copiate_dinMunca!$ ncdump -h wrfout_d01_2010-05-01_daily.nc netcdf wrfout_d01_2010-05-01_daily { dimensions: Time = UNLIMITED ; // (1 currently) south_north = 159 ; west_east = 189 ; DateStrLen = 19 ; variables: float AOD2D55(Time, south_north, west_east) ; AOD2D55:FieldType = 104 ; AOD2D55:MemoryOrder = "XY " ; AOD2D55:description = "Aerosol optical depth for .55um" ; AOD2D55:units = "" ; AOD2D55:stagger = "" ; AOD2D55:coordinates = "XLONG XLAT XTIME" ; char Times(Time, DateStrLen) ; float XTIME(Time) ; XTIME:FieldType = 104 ; XTIME:MemoryOrder = "0 " ; XTIME:description = "minutes since 2008-12-01 00:00:00" ; XTIME:units = "minutes since 2008-12-01 00:00:00" ; XTIME:stagger = "" ;

// global attributes: :TITLE = " OUTPUT FROM * PROGRAM:WRF-Chem V3.9.1.1 MODEL" ; :START_DATE = "2010-01-01_00:00:00" ; :SIMULATION_START_DATE = "2008-12-01_00:00:00" ; :WEST-EAST_GRID_DIMENSION = 190 ; :SOUTH-NORTH_GRID_DIMENSION = 160 ; :BOTTOM-TOP_GRID_DIMENSION = 50 ; :DX = 25000.f ; :DY = 25000.f ; :SKEBS_ON = 0 ; :SPEC_BDY_FINAL_MU = 1 ; :USE_Q_DIABATIC = 0 ; :GRIDTYPE = "C" ; :DIFF_OPT = 1 ; :KM_OPT = 4 ; :DAMP_OPT = 3 ; :DAMPCOEF = 0.2f ; :KHDIF = 0.f ; :KVDIF = 0.f ; :MP_PHYSICS = 10 ; :RA_LW_PHYSICS = 4 ; :RA_SW_PHYSICS = 4 ; :SF_SFCLAY_PHYSICS = 5 ; :SF_SURFACE_PHYSICS = 2 ; :BL_PBL_PHYSICS = 5 ; :CU_PHYSICS = 3 ; :SF_LAKE_PHYSICS = 0 ; :SURFACE_INPUT_SOURCE = 1 ; :SST_UPDATE = 1 ; :GRID_FDDA = 2 ; :GFDDA_INTERVAL_M = 360 ; :GFDDA_END_H = 1000000 ; :GRID_SFDDA = 0 ; :SGFDDA_INTERVAL_M = 0 ; :SGFDDA_END_H = 0 ; :HYPSOMETRIC_OPT = 2 ; :USE_THETA_M = 0 ; :GWD_OPT = 0 ; :SF_URBAN_PHYSICS = 0 ; :SF_OCEAN_PHYSICS = 0 ; :SHCU_PHYSICS = 3 ; :MFSHCONV = 0 ; :FEEDBACK = 0 ; :SMOOTH_OPTION = 0 ; :SWRAD_SCAT = 1.f ; :W_DAMPING = 1 ; :DT = 99.995f ; :ADAPT_DT_START = 150.f ; :ADAPT_DT_MAX = 200.f ; :ADAPT_DT_MIN = 25.f ; :RADT = 30.f ; :BLDT = 0.f ; :CUDT = 0.f ; :AER_OPT = 0 ; :SWINT_OPT = 0 ; :AER_TYPE = 1 ; :AER_AOD550_OPT = 1 ; :AER_ANGEXP_OPT = 1 ; :AER_SSA_OPT = 1 ; :AER_ASY_OPT = 1 ; :AER_AOD550_VAL = 0.12f ; :AER_ANGEXP_VAL = 1.3f ; :AER_SSA_VAL = 0.85f ; :AER_ASY_VAL = 0.9f ; :MOIST_ADV_OPT = 2 ; :SCALAR_ADV_OPT = 2 ; :TKE_ADV_OPT = 1 ; :DIFF_6TH_OPT = 0 ; :DIFF_6TH_FACTOR = 0.12f ; :FGDT = 0.f ; :GUV = 0.0003f ; :GT = 0.0003f ; :GPH = 0.0003f ; :IF_RAMPING = 0 ; :DTRAMP_MIN = 60.f ; :OBS_NUDGE_OPT = 0 ; :BUCKET_MM = 1000.f ; :BUCKET_J = 1.e+10f ; :PREC_ACC_DT = 0.f ; :ISFTCFLX = 0 ; :ISHALLOW = 0 ; :ISFFLX = 1 ; :ICLOUD = 4 ; :ICLOUD_CU = 0 ; :TRACER_PBLMIX = 1 ; :SCALAR_PBLMIX = 0 ; :YSU_TOPDOWN_PBLMIX = 0 ; :GRAV_SETTLING = 0 ; :DFI_OPT = 0 ; :SIMULATION_INITIALIZATION_TYPE = "REAL-DATA CASE" ; :WEST-EAST_PATCH_START_UNSTAG = 1 ; :WEST-EAST_PATCH_END_UNSTAG = 189 ; :WEST-EAST_PATCH_START_STAG = 1 ; :WEST-EAST_PATCH_END_STAG = 190 ; :SOUTH-NORTH_PATCH_START_UNSTAG = 1 ; :SOUTH-NORTH_PATCH_END_UNSTAG = 159 ; :SOUTH-NORTH_PATCH_START_STAG = 1 ; :SOUTH-NORTH_PATCH_END_STAG = 160 ; :BOTTOM-TOP_PATCH_START_UNSTAG = 1 ; :BOTTOM-TOP_PATCH_END_UNSTAG = 49 ; :BOTTOM-TOP_PATCH_START_STAG = 1 ; :BOTTOM-TOP_PATCH_END_STAG = 50 ; :GRID_ID = 1 ; :PARENT_ID = 0 ; :I_PARENT_START = 1 ; :J_PARENT_START = 1 ; :PARENT_GRID_RATIO = 1 ; :CEN_LAT = 49.42485f ; :CEN_LON = 5.271393f ; :TRUELAT1 = 50.f ; :TRUELAT2 = 50.f ; :MOAD_CEN_LAT = 49.42485f ; :STAND_LON = 7.f ; :POLE_LAT = 90.f ; :POLE_LON = 0.f ; :GMT = 0.f ; :JULYR = 2010 ; :JULDAY = 1 ; :MAP_PROJ = 1 ; :MAP_PROJ_CHAR = "Lambert Conformal" ; :MMINLU = "MODIFIED_IGBP_MODIS_NOAH" ; :NUM_LAND_CAT = 21 ; :ISWATER = 17 ; :ISLAKE = 21 ; :ISICE = 15 ; :ISURBAN = 13 ; :ISOILWATER = 14 ; :HYBRID_OPT = -1 ; :ETAC = 0.f ; :NCO = "netCDF Operators version 4.7.9 (Homepage = http://nco.sf.net, Code = http://github.com/nco/nco)" ; :history = "Mon Jan 17 17:38:30 2022: ncatted -a history,global,d,, wrfout_d01_2010-05-01_daily.nc -O wrfout_d01_2010-05-01_daily.nc" ;} `

wrightwx commented 2 years ago

Thanks for the note... Nope, did not resolve it. I had too many fires going to address it more deeply. I had to move on to other datasets and other projects, but I will eventually have to address this. Let me know if you happen to resolve it.

Tim

On Thu, Jan 27, 2022 at 2:57 AM georgeboldeanu @.***> wrote:

Hi! I have the same Issue as @wrightwx https://github.com/wrightwx. Here is the error from QGIS log:

2022-01-27T11:37:40 WARNING Traceback (most recent call last): File "C:/Users/george.boldeanu/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gis4wrf\plugin\ui\widget_view.py", line 255, in on_variable_selected self.replace_variable_layer() File "C:/Users/george.boldeanu/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gis4wrf\plugin\ui\widget_view.py", line 297, in replace_variable_layer dataset.path, variable.name, extra_dim_index, interp_level, interp_vert_name) File "C:/Users/george.boldeanu/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gis4wrf\core\transforms\wrf_netcdf_to_gdal.py", line 140, in convert_wrf_nc_var_to_gdal_dataset geo_transform = get_geo_transform(ds, crs) File "C:/Users/george.boldeanu/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gis4wrf\core\transforms\wrf_netcdf_to_gdal.py", line 446, in get_geo_transform lons_u = ds.variables['XLONG_U'] KeyError: 'XLONG_U'

Also as @letmaik https://github.com/letmaik recommend I got a ncdump info about the file:

@.***_HpWorker:/mnt/f/Copiate_dinMunca!$ ncdump -h wrfout_d01_2010-05-01_daily.nc netcdf wrfout_d01_2010-05-01_daily { dimensions: Time = UNLIMITED ; // (1 currently) south_north = 159 ; west_east = 189 ; DateStrLen = 19 ; variables: float AOD2D55(Time, south_north, west_east) ; AOD2D55:FieldType = 104 ; AOD2D55:MemoryOrder = "XY " ; AOD2D55:description = "Aerosol optical depth for .55um" ; AOD2D55:units = "" ; AOD2D55:stagger = "" ; AOD2D55:coordinates = "XLONG XLAT XTIME" ; char Times(Time, DateStrLen) ; float XTIME(Time) ; XTIME:FieldType = 104 ; XTIME:MemoryOrder = "0 " ; XTIME:description = "minutes since 2008-12-01 00:00:00" ; XTIME:units = "minutes since 2008-12-01 00:00:00" ; XTIME:stagger = "" ;

// global attributes: :TITLE = " OUTPUT FROM * PROGRAM:WRF-Chem V3.9.1.1 MODEL" ; :START_DATE = "2010-01-01_00:00:00" ; :SIMULATION_START_DATE = "2008-12-01_00:00:00" ; :WEST-EAST_GRID_DIMENSION = 190 ; :SOUTH-NORTH_GRID_DIMENSION = 160 ; :BOTTOM-TOP_GRID_DIMENSION = 50 ; :DX = 25000.f ; :DY = 25000.f ; :SKEBS_ON = 0 ; :SPEC_BDY_FINAL_MU = 1 ; :USE_Q_DIABATIC = 0 ; :GRIDTYPE = "C" ; :DIFF_OPT = 1 ; :KM_OPT = 4 ; :DAMP_OPT = 3 ; :DAMPCOEF = 0.2f ; :KHDIF = 0.f ; :KVDIF = 0.f ; :MP_PHYSICS = 10 ; :RA_LW_PHYSICS = 4 ; :RA_SW_PHYSICS = 4 ; :SF_SFCLAY_PHYSICS = 5 ; :SF_SURFACE_PHYSICS = 2 ; :BL_PBL_PHYSICS = 5 ; :CU_PHYSICS = 3 ; :SF_LAKE_PHYSICS = 0 ; :SURFACE_INPUT_SOURCE = 1 ; :SST_UPDATE = 1 ; :GRID_FDDA = 2 ; :GFDDA_INTERVAL_M = 360 ; :GFDDA_END_H = 1000000 ; :GRID_SFDDA = 0 ; :SGFDDA_INTERVAL_M = 0 ; :SGFDDA_END_H = 0 ; :HYPSOMETRIC_OPT = 2 ; :USE_THETA_M = 0 ; :GWD_OPT = 0 ; :SF_URBAN_PHYSICS = 0 ; :SF_OCEAN_PHYSICS = 0 ; :SHCU_PHYSICS = 3 ; :MFSHCONV = 0 ; :FEEDBACK = 0 ; :SMOOTH_OPTION = 0 ; :SWRAD_SCAT = 1.f ; :W_DAMPING = 1 ; :DT = 99.995f ; :ADAPT_DT_START = 150.f ; :ADAPT_DT_MAX = 200.f ; :ADAPT_DT_MIN = 25.f ; :RADT = 30.f ; :BLDT = 0.f ; :CUDT = 0.f ; :AER_OPT = 0 ; :SWINT_OPT = 0 ; :AER_TYPE = 1 ; :AER_AOD550_OPT = 1 ; :AER_ANGEXP_OPT = 1 ; :AER_SSA_OPT = 1 ; :AER_ASY_OPT = 1 ; :AER_AOD550_VAL = 0.12f ; :AER_ANGEXP_VAL = 1.3f ; :AER_SSA_VAL = 0.85f ; :AER_ASY_VAL = 0.9f ; :MOIST_ADV_OPT = 2 ; :SCALAR_ADV_OPT = 2 ; :TKE_ADV_OPT = 1 ; :DIFF_6TH_OPT = 0 ; :DIFF_6TH_FACTOR = 0.12f ; :FGDT = 0.f ; :GUV = 0.0003f ; :GT = 0.0003f ; :GPH = 0.0003f ; :IF_RAMPING = 0 ; :DTRAMP_MIN = 60.f ; :OBS_NUDGE_OPT = 0 ; :BUCKET_MM = 1000.f ; :BUCKET_J = 1.e+10f ; :PREC_ACC_DT = 0.f ; :ISFTCFLX = 0 ; :ISHALLOW = 0 ; :ISFFLX = 1 ; :ICLOUD = 4 ; :ICLOUD_CU = 0 ; :TRACER_PBLMIX = 1 ; :SCALAR_PBLMIX = 0 ; :YSU_TOPDOWN_PBLMIX = 0 ; :GRAV_SETTLING = 0 ; :DFI_OPT = 0 ; :SIMULATION_INITIALIZATION_TYPE = "REAL-DATA CASE" ; :WEST-EAST_PATCH_START_UNSTAG = 1 ; :WEST-EAST_PATCH_END_UNSTAG = 189 ; :WEST-EAST_PATCH_START_STAG = 1 ; :WEST-EAST_PATCH_END_STAG = 190 ; :SOUTH-NORTH_PATCH_START_UNSTAG = 1 ; :SOUTH-NORTH_PATCH_END_UNSTAG = 159 ; :SOUTH-NORTH_PATCH_START_STAG = 1 ; :SOUTH-NORTH_PATCH_END_STAG = 160 ; :BOTTOM-TOP_PATCH_START_UNSTAG = 1 ; :BOTTOM-TOP_PATCH_END_UNSTAG = 49 ; :BOTTOM-TOP_PATCH_START_STAG = 1 ; :BOTTOM-TOP_PATCH_END_STAG = 50 ; :GRID_ID = 1 ; :PARENT_ID = 0 ; :I_PARENT_START = 1 ; :J_PARENT_START = 1 ; :PARENT_GRID_RATIO = 1 ; :CEN_LAT = 49.42485f ; :CEN_LON = 5.271393f ; :TRUELAT1 = 50.f ; :TRUELAT2 = 50.f ; :MOAD_CEN_LAT = 49.42485f ; :STAND_LON = 7.f ; :POLE_LAT = 90.f ; :POLE_LON = 0.f ; :GMT = 0.f ; :JULYR = 2010 ; :JULDAY = 1 ; :MAP_PROJ = 1 ; :MAP_PROJ_CHAR = "Lambert Conformal" ; :MMINLU = "MODIFIED_IGBP_MODIS_NOAH" ; :NUM_LAND_CAT = 21 ; :ISWATER = 17 ; :ISLAKE = 21 ; :ISICE = 15 ; :ISURBAN = 13 ; :ISOILWATER = 14 ; :HYBRID_OPT = -1 ; :ETAC = 0.f ; :NCO = "netCDF Operators version 4.7.9 (Homepage = http://nco.sf.net, Code = http://github.com/nco/nco https://github.com/nco/nco)" ; :history = "Mon Jan 17 17:38:30 2022: ncatted -a history,global,d,, wrfout_d01_2010-05-01_daily.nc -O wrfout_d01_2010-05-01_daily.nc" ;} `

— Reply to this email directly, view it on GitHub https://github.com/GIS4WRF/gis4wrf/issues/166#issuecomment-1023035602, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOY525XIBK3RKOXM3A6WN53UYEJHZANCNFSM4LEPCHIA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

letmaik commented 2 years ago

@wrightwx Were you also using wrf-chem? Normally, regular wrf out files have a bunch of coordinate variables which seem to be missing here. The plugin relies on those to compute the geo transform.

wrightwx commented 2 years ago

No, it was not WRF chem. It was a nested run (433m grid) over southern California.

Tim

On Thu, Jan 27, 2022 at 10:33 AM Maik Riechert @.***> wrote:

@wrightwx https://github.com/wrightwx Were you also using wrf-chem? Normally, regular wrf out files have a bunch of coordinate variables which seem to be missing here. The plugin relies on those to compute the geo transform.

— Reply to this email directly, view it on GitHub https://github.com/GIS4WRF/gis4wrf/issues/166#issuecomment-1023474080, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOY525WQ5AHIIHKVWGCX463UYF6W5ANCNFSM4LEPCHIA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>