... | ... | @@ -32,6 +32,30 @@ biome.warning = '1:amazon, 2:caatinga, 3:cerrado, 4:mata atlantica, 5:pampas, 6: |
|
|
file_netcdf.close()
|
|
|
```
|
|
|
|
|
|
## string and char
|
|
|
### with 'NETCDF4'
|
|
|
```
|
|
|
file_netcdf = Dataset(file_name,'w', format='NETCDF4'
|
|
|
|
|
|
landuse_name = np.array(landuses, dtype='object')
|
|
|
biome_name = np.array(biomes, dtype='object')
|
|
|
|
|
|
file_netcdf.createDimension('landuse', len(landuse_name))
|
|
|
file_netcdf.createDimension('biome', len(biome_name))
|
|
|
|
|
|
landuse = file_netcdf.createVariable('landuse', str, 'landuse')
|
|
|
biome = file_netcdf.createVariable('biome', str, 'biome')
|
|
|
|
|
|
landuse[:] = landuse_name
|
|
|
biome[:] = biome_name
|
|
|
```
|
|
|
### with 'NETCDF3' or 'NETCDF4_CLASSIC'
|
|
|
```
|
|
|
landuse_name = stringtochar(np.array(landuses, 'S33'))
|
|
|
biome_name = stringtochar(np.array(biomes, 'S13'))
|
|
|
#need to be check
|
|
|
```
|
|
|
|
|
|
# how to read
|
|
|
```
|
|
|
nc = Dataset("/landuse/users/brunel/chalumeau_tillage/run_set_01/nf_001/vegc.nc", mode='r')
|
... | ... | @@ -39,4 +63,6 @@ variables = nc.variables.keys() |
|
|
for variable in variables :
|
|
|
print(nc.variables[variable][:])
|
|
|
nc.close()
|
|
|
``` |
|
|
\ No newline at end of file |
|
|
```
|
|
|
## how to read char
|
|
|
`chartostring()` |
|
|
\ No newline at end of file |