Last change
on this file since 5508 was
2146,
checked in by acosce, 11 years ago
|
- make some correction in prepare_aerosol_climato_annuel
- lev_file.nc is the netcdf file with lev / ap / b variables use in aerosol concentration file in 969539
- correction_axe.py is a script use to invert lev axis to create previous file (lev_file.nc) from cmor output
|
File size:
1.3 KB
|
Line | |
---|
1 | #!/usr/bin/env python |
---|
2 | # script pour lire et reecrire des variables avec des 'lev' de 0 a 1 |
---|
3 | |
---|
4 | # pour commencer on importe le module de lecture et manipulation |
---|
5 | # de variables avec axes |
---|
6 | |
---|
7 | |
---|
8 | # commandes pour lancer le script : |
---|
9 | # source ~p25jype/CDAT/Install/cdat_multi/cdat_multi.login ~p25jype/CDAT/Install/cdat_multi |
---|
10 | # python correction_axe.py |
---|
11 | |
---|
12 | |
---|
13 | import cdms2 as c |
---|
14 | |
---|
15 | # pour eviter d avoir du netcdf4 a la fin... |
---|
16 | |
---|
17 | c.setNetcdfShuffleFlag(0) ## where value is either 0 or 1 |
---|
18 | c.setNetcdfDeflateFlag(0) ## where value is either 0 or 1 |
---|
19 | c.setNetcdfDeflateLevelFlag(0) ## where value is a integer between 0 and 9 included |
---|
20 | |
---|
21 | # ouverture du fichier d entree |
---|
22 | f = c.open('/ccc/scratch/cont003/dsm/p86cozic/CLIMATO/cmor_lev.nc') |
---|
23 | |
---|
24 | # ouverture du fichier de sortie |
---|
25 | g = c.open('/ccc/scratch/cont003/dsm/p86cozic/CLIMATO/FILES/lev_file.nc','w') |
---|
26 | |
---|
27 | # on recupere la liste des variables |
---|
28 | liste_variables = f.listvariables() |
---|
29 | |
---|
30 | # boucle sur la liste des variables |
---|
31 | for var in liste_variables: |
---|
32 | print "on s occupe de ",var |
---|
33 | # lecture de la variable |
---|
34 | v = f(var) |
---|
35 | # si variable a plusieurs dimensions |
---|
36 | #et si lev est l'une de ces dimensions |
---|
37 | if len(v.shape) != 0 and 'lev' in v.getAxisIds(): |
---|
38 | g.write(v(lev=(0,1,'cc'))) |
---|
39 | else: |
---|
40 | g.write(v,id=var) |
---|
41 | |
---|
42 | # fermeture des fichiers |
---|
43 | f.close() |
---|
44 | g.close() |
---|
Note: See
TracBrowser
for help on using the repository browser.