Comments (12)
@pernak18 I'm hoping you can use some Python-fu here? Roughly we want a PR with a new SW coefficients file that has precisely the same structure but a revised dimension name consistent with the LW file.
from rte-rrtmgp.
@RobertPincus sounds doable, but will have to wait until i have some free time. i'm a pretty small line item in Eli's budget for April
from rte-rrtmgp.
problem was more complex than i thought it would be, but the code i used at NERSC (cori
) is:
#!/usr/bin/env python
import os, sys
PIPPATH = '{}/.local/'.format(os.path.expanduser('~')) + \
'cori/3.7-anaconda-2019.10/lib/python3.7/site-packages'
paths = [PIPPATH, '../common']
for path in paths: sys.path.append(path)
import xarray as xa
import numpy as np
strVars = ['gas_minor', 'gas_names', 'identifier_minor',
'minor_gases_lower', 'minor_gases_upper',
'scaling_gas_lower', 'scaling_gas_upper']
ncFile = 'rrtmgp-data-sw-g224-2018-12-04.nc'
outDS = xa.Dataset()
with xa.open_dataset(ncFile, concat_characters=False) as ds:
outDS.attrs = ds.attrs
ncVars = list(ds.keys())
for ncVar in ncVars:
inDat = ds[ncVar]
if ncVar in strVars:
inDat = inDat.astype(str)
strings = [''.join(string) for string in inDat.values]
outDS[ncVar] = xa.DataArray(
np.array(strings, dtype=np.dtype(('S', 32))),
dims=[inDat.dims[0]], attrs=inDat.attrs)
else:
outDS[ncVar] = ds[ncVar]
# endif ncVar
# end ncVar loop
# endwith
# https://github.com/pydata/xarray/issues/2899
# workaround is admittedly not the solution we want (arrays end up being strings)
# but it leads to https://github.com/pydata/xarray/issues/3407#issuecomment-542594876
# which solves our problem and is what was implemented
outNC = 'modified_{}'.format(ncFile)
encode = {}
for sv in strVars:
encode[sv] = {'zlib':True, 'complevel':5, 'char_dim_name': 'string_len'}
outDS.to_netcdf(outNC, encoding=encode, format='NETCDF3_CLASSIC')
print('Wrote {}'.format(outNC))
i apparently cannot attach the resulting file in this issue. do we want this code somewhere in version control, or does the code snippet suffice?
from rte-rrtmgp.
This seems awesome, @pernak18, thanks so much. Can you open a PR against develop
in which you update rrtmgp/data/rrtmgp-data-sw-g224-2018-12-04.nc
to use the file with the renamed dimension? Having the code in the issue and/or PR is enough, I think.
from rte-rrtmgp.
for my reference:
% pwd
/global/homes/p/pernak18/RRTMGP/rte-rrtmgp
% git branch rp_dev
% git checkout rp_dev
Switched to branch 'rp_dev'
% cd rrtmgp/data/
% cp ~/RRTMGP/g-point-reduction/dim_swap/modified_rrtmgp-data-sw-g224-2018-12-04.nc rrtmgp-data-sw-g224-2018-12-04.nc
cp: overwrite 'rrtmgp-data-sw-g224-2018-12-04.nc'? y
on cori
.
needed my own branch before creating Pull Request (I don't have permissions on develop
).
from rte-rrtmgp.
The files in the new main
repository have inconsistent NetCDF
types:
chiel@MacBookChiel:~/devel/radiation/rte-rrtmgp/rrtmgp/data$ ncdump -k rrtmgp-data-sw-g224-2018-12-04.nc
netCDF-4
chiel@MacBookChiel:~/devel/radiation/rte-rrtmgp/rrtmgp/data$ ncdump -k rrtmgp-data-lw-g256-2018-12-04.nc
classic
from rte-rrtmgp.
thanks for noticing
from rte-rrtmgp.
@RobertPincus does this mean we want to switch LW to netCDF-4
or SW to classic
?
from rte-rrtmgp.
@pernak18 I'm not sure it matters, netCDF-4
is the future though. @Chiil do you have an opinion?
from rte-rrtmgp.
HI,
I do not think that netcdf-4 is the future after the hdf group changed there working model. I think for such small files the netcdf classic format (aka netcdf-3 is best.
Cheerio,
Luis
from rte-rrtmgp.
i've converted SW to classic
. xarray
has 4 different options, and i initially went with NETCDF4_CLASSIC
as a combination of both but then decided to stay consistent with the LW, so:
outDS.to_netcdf(outNC, encoding=encode, format='NETCDF3_CLASSIC')
from rte-rrtmgp.
Fixed in commit cd7a6c2
(#109)
from rte-rrtmgp.
Related Issues (20)
- gpt_Jac optional arguement code may be incorrect for OpenMP offload HOT 2
- Units in cloud optics extension? HOT 3
- RFMIP clear sky test failing with forcing index != 1 HOT 1
- A flexible benchmarking program HOT 4
- Kernel arguments HOT 4
- Small bug in mo_gas_optics_rrtmgp.F90 HOT 1
- Potential indexing error rte/kernels-openacc/mo_rte_solver_kernels.F90 HOT 2
- Optimized compiler flags for PGI incorrect HOT 3
- RRTMGP and Single Precision HOT 11
- Generic names in C bindings HOT 1
- Intel Compiler Optimization Problem on AMD EPYC ( Milan ) HOT 10
- Request for data files names to use ISO dates HOT 2
- Memory layout in gas optics kernels HOT 2
- Macro name in build system HOT 2
- Testing OpenMP GPU offload with Intel OneAPI compilers HOT 3
- Data external to code repo? HOT 15
- Inconsistent RRTMGP results on CPU with different code paths HOT 23
- Removing dtc/ccpp branch HOT 6
- Bug in rrtmgp/kernels/mo_gas_optics_kernels.F90 HOT 5
- RTE shortwave kernel not vectorizing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rte-rrtmgp.