Skip to content
Snippets Groups Projects
Select Git revision
  • ab8049eab81c55824aec5b26e3ac27d9034826a2
  • master default protected
  • dev protected
  • replication_test
  • 551-init-broker-service-permissions
  • release-1.10 protected
  • 549-test-oai-pmh
  • 545-saving-multiple-times-breaks-pid-metadata
  • release-1.9 protected
  • 499-standalone-compute-service-2
  • 539-load-tests
  • hotfix/helm-chart
  • luca_ba_new_interface
  • 534-bug-when-adding-access-to-user-that-is-not-registered-at-dashboard-service
  • release-1.8 protected
  • 533-integrate-semantic-recommendation
  • feature/openshift
  • 518-spark-doesn-t-map-the-headers-correct
  • 485-fixity-checks
  • 530-various-schema-problems-with-subsets
  • release-1.7 protected
  • v1.10.1 protected
  • v1.10.0-rc13 protected
  • v1.10.0-rc12 protected
  • v1.10.0-rc11 protected
  • v1.10.0-rc10 protected
  • v1.10.0-rc9 protected
  • v1.10.0-rc8 protected
  • v1.10.0-rc7 protected
  • v1.10.0-rc6 protected
  • v1.10.0-rc5 protected
  • v1.10.0-rc4 protected
  • v1.10.0-rc3 protected
  • v1.10.0-rc2 protected
  • v1.10.0rc1 protected
  • v1.10.0rc0 protected
  • v1.10.0 protected
  • v1.9.3 protected
  • v1.9.2 protected
  • v1.9.2-rc0 protected
  • v1.9.1 protected
41 results

Pipfile

Blame
  • wrfout_add_geo.py 1.47 KiB
    """Add geogrid data to wrfinput
    DART needs a georeference, but ideal.exe does not provide it
    
    Takes LAT,LON, mapfac from geogrid, so that they are consistent.
    Does not change E, F, HGT_M as they would alter the dynamics and have no impact on assimilation
    
    Example call:
        ./wrfout_add_geo.py geo_em.d01.nc wrfinput_d01
    """
    import os, sys
    import netCDF4 as nc
    from config.cfg import exp, cluster
    
    fields_old = ["XLAT_M",   "XLONG_M",      "CLAT",
                    "XLONG_U",  "XLONG_V",     "XLAT_U",    "XLAT_V"]
    fields_new = ["XLAT",     "XLONG",      "CLAT",
                    "XLONG_U",  "XLONG_V",     "XLAT_U",    "XLAT_V"]
    
    def run(geo_data_file, wrfout_file):
        debug = False
    
        print('updating geodata in', wrfout_file, 'from', geo_data_file)
        geo_ds = nc.Dataset(geo_data_file, 'r')
        wrfinp_ds = nc.Dataset(wrfout_file, 'r+')
    
        for old, new in zip(fields_old, fields_new):
            if debug:
                print('moving old field', old, 'into new field', new)
                print(geo_ds.variables[old][:].shape, wrfinp_ds.variables[new][:].shape)
            wrfinp_ds.variables[new][:] = geo_ds.variables[old][:]
    
        wrfinp_ds.close()
        geo_ds.close()
    
        # overwrite attributes
        os.system(cluster.ncks+' -A -x '+geo_data_file+' '+wrfout_file)
    
    
    if __name__ == '__main__':
        geo_data_file = sys.argv[1]  # '/home/fs71386/lkugler/compile_WRF/WPS-release-v4.2/geo_em.d01.nc'
        wrfout_file = sys.argv[2]  # '/home/fs71386/lkugler/DART/wrfinput_d01'
    
        run(geo_data_file, wrfout_file)