Changes between Version 3 and Version 4 of NCMLUserStories
- Timestamp:
- Apr 30, 2016 6:32:58 PM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
NCMLUserStories
v3 v4 8 8 9 9 * [http://www.unidata.ucar.edu/software/thredds/current/netcdf-java/ncml/ NetCDF Markup Language (NcML)]: NcML is an XML representation of netCDF metadata. NcML is similar to the netCDF CDL (network Common data form Description Language), except, of course, it uses XML syntax. 10 * '''How to define new dimensions or correct/modify existing ones?''' 10 11 == Examples == 12 13 * '''How to modify the values of a variable in a netcdf file?''' 14 Ncml could be a useful tool to manipulate netcdf files. In this example, we are going to describe how to modify the values of a particular variable (rlat) in an existing netcdf file (tas.nc). 15 16 For this purpuse it is necessary to generate a ncml that refers to that particular netcdf, by adding a location argument. Then, we just need to specify the variable name that we want to change, their values and the separator between them. The ncml file will look something like this: 17 {{{ 18 <?xml version="1.0" encoding="UTF-8"?> 19 <ncml:netcdf xmlns:ncml="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" location="tas.nc"> 20 <ncml:variable name="rlat"> 21 <ncml:values separator=","> 22 0.883846282958984, 1.10384750366211, 1.32384872436523, 1.54384613037109, 1.76384735107422, 1.98384857177734, 2.2038459777832, 2.42384719848633, 2.64384841918945, 2.86384773254395, 3.08384704589844, 3.30384826660156, 3.52384757995605, 3.74384689331055, 3.96384811401367, 4.18384742736816, 4.40384674072266, 4.62384796142578, 4.84384727478027, 5.06384658813477, 5.28384780883789, 5.50384712219238, 5.72384834289551, 5.94384765625, 6.16384696960449, 6.38384819030762, 6.60384750366211, 6.8238468170166, 7.04384803771973, 7.26384735107422, 7.48384666442871,7.70384788513184, 7.92384719848633, 8.14384841918945, 8.36384773254395, 8.58384704589844, 8.80384826660156, 9.02384757995605, 9.24384689331055, 9.46384811401367, 9.68384742736816, 9.90384674072266, 10.1238479614258, 10.3438472747803, 10.5638465881348, 10.7838478088379, 11.0038471221924, 11.2238483428955, 11.44384765625, 11.6638469696045, 11.8838481903076, 12.1038475036621, 12.3238468170166, 12.5438480377197, 12.7638473510742, 12.9838466644287, 13.2038478851318, 13.4238471984863, 13.6438484191895, 13.8638477325439, 14.0838470458984, 14.3038482666016, 14.5238475799561, 14.7438468933105, 14.9638481140137, 15.1838474273682, 15.4038467407227, 15.6238479614258, 15.8438472747803, 16.0638465881348, 16.2838478088379, 16.5038471221924, 16.7238483428955, 16.94384765625, 17.1638469696045, 17.3838481903076, 17.6038475036621, 17.8238468170166, 18.0438480377197, 18.2638473510742, 18.4838466644287, 18.7038478851318, 18.9238471984863, 19.1438484191895, 19.3638477325439, 19.5838470458984, 19.8038482666016, 20.0238475799561, 20.2438468933105, 20.4638481140137, 20.6838474273682, 20.9038467407227, 21.1238479614258, 21.3438472747803, 21.5638465881348, 21.7838478088379, 22.0038471221924, 22.2238464355469, 22.44384765625, 22.6638469696045, 22.883846282959, 23.1038475036621, 23.3238487243652, 23.5438461303711, 23.7638473510742, 23.9838485717773, 24.2038478851318, 24.4238471984863, 24.6438484191895, 24.8638477325439, 25.0838470458984, 25.3038482666016, 25.5238475799561, 25.7438468933105, 25.9638481140137, 26.1838474273682, 26.4038467407227, 26.6238479614258, 26.8438472747803, 27.0638465881348, 27.2838478088379, 27.5038471221924, 27.7238464355469, 27.94384765625, 28.1638469696045, 28.383846282959, 28.6038475036621, 28.8238468170166, 29.0438480377197, 29.2638473510742, 29.4838485717773, 29.7038478851318, 29.9238471984863, 30.1438484191895, 30.3638477325439, 30.5838470458984, 30.8038482666016, 31.0238475799561, 31.2438468933105, 31.4638481140137, 31.6838474273682, 31.9038467407227, 32.1238479614258, 32.3438491821289, 32.5638465881348, 32.7838478088379, 33.003849029541, 33.2238464355469, 33.44384765625, 33.6638488769531, 33.883846282959, 34.1038475036621, 34.3238487243652, 34.5438461303711, 34.7638473510742, 34.9838485717773, 35.2038459777832, 35.4238471984863, 35.6438484191895, 35.8638458251953, 36.0838470458984, 36.3038482666016, 36.5238456726074, 36.7438468933105, 36.9638481140137, 37.1838455200195, 37.4038467407227 23 </ncml:values> 24 </ncml:variable> 25 </ncml:netcdf> 26 }}} 27 In order to save the changes in a new netcdf file, we can use toolsUI. 28 {{{ 29 java -cp /software/meteo/jar/toolsUI-4.6.5.jar ucar.nc2.write.Nccopy --input rlat_new.ncml --output tas_new.nc --format netcdf4_classic -d 4 -sh 30 }}} 31 32 * '''How to define new dimensions or correct/modify existing ones?''' 11 33 {{{ 12 34 <?xml version="1.0" encoding="UTF-8"?> … … 17 39 </ncml:netcdf> 18 40 }}} 19 * '''How to define new variables or correct/modify existing ones?''' 41 42 * '''How to define new variables or correct/modify existing ones?''' 20 43 {{{ 21 44 <?xml version="1.0" encoding="UTF-8"?> … … 51 74 </ncml:netcdf> 52 75 }}} 53 * '''How to aggregate datasets?''' 54 {{{ 55 <!-- 56 Union of variables stored en different files 57 --> 76 77 * '''How to aggregate datasets?''' 78 {{{ 58 79 <?xml version="1.0" encoding="UTF-8"?> 59 80 <ncml:netcdf xmlns:ncml="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" location="dods://opendap.knmi.nl/knmi/thredds/dodsC/e-obs_0.25regular/pp_0.25deg_reg_v12.0.nc"> … … 69 90 </ncml:aggregation> 70 91 </ncml:netcdf> 71 72 <!-- 73 Union along an existing dimension 74 --> 75 92 }}} 93 94 * '''How to aggregate files along an existing dimension?''' 95 {{{ 76 96 <?xml version="1.0" encoding="UTF-8"?> 77 97 <ncml:netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2"> … … 109 129 </ncml:aggregation> 110 130 </ncml:netcdf> 111 112 113 <!-- 114 Union along a new dimension 115 --> 116 131 }}} 132 133 * '''How to aggregate files along a new dimension?''' 134 {{{ 117 135 <?xml version="1.0" encoding="UTF-8"?> 118 136 <netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2"> … … 185 203 }}} 186 204 187 == Examples ==188 * '''How to modify the values of a variable in a netcdf file?'''189 Ncml could be a useful tool to manipulate netcdf files. In this example, we are going to describe how to modify the values of a particular variable (rlat) in an existing netcdf file (tas.nc).190 191 For this purpuse it is necessary to generate a ncml that refers to that particular netcdf, by adding a location argument. Then, we just need to specify the variable name that we want to change, their values and the separator between them. The ncml file will look something like this:192 {{{193 <?xml version="1.0" encoding="UTF-8"?>194 <ncml:netcdf xmlns:ncml="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" location="tas.nc">195 <ncml:variable name="rlat">196 <ncml:values separator=",">197 0.883846282958984, 1.10384750366211, 1.32384872436523, 1.54384613037109, 1.76384735107422, 1.98384857177734, 2.2038459777832, 2.42384719848633, 2.64384841918945, 2.86384773254395, 3.08384704589844, 3.30384826660156, 3.52384757995605, 3.74384689331055, 3.96384811401367, 4.18384742736816, 4.40384674072266, 4.62384796142578, 4.84384727478027, 5.06384658813477, 5.28384780883789, 5.50384712219238, 5.72384834289551, 5.94384765625, 6.16384696960449, 6.38384819030762, 6.60384750366211, 6.8238468170166, 7.04384803771973, 7.26384735107422, 7.48384666442871,7.70384788513184, 7.92384719848633, 8.14384841918945, 8.36384773254395, 8.58384704589844, 8.80384826660156, 9.02384757995605, 9.24384689331055, 9.46384811401367, 9.68384742736816, 9.90384674072266, 10.1238479614258, 10.3438472747803, 10.5638465881348, 10.7838478088379, 11.0038471221924, 11.2238483428955, 11.44384765625, 11.6638469696045, 11.8838481903076, 12.1038475036621, 12.3238468170166, 12.5438480377197, 12.7638473510742, 12.9838466644287, 13.2038478851318, 13.4238471984863, 13.6438484191895, 13.8638477325439, 14.0838470458984, 14.3038482666016, 14.5238475799561, 14.7438468933105, 14.9638481140137, 15.1838474273682, 15.4038467407227, 15.6238479614258, 15.8438472747803, 16.0638465881348, 16.2838478088379, 16.5038471221924, 16.7238483428955, 16.94384765625, 17.1638469696045, 17.3838481903076, 17.6038475036621, 17.8238468170166, 18.0438480377197, 18.2638473510742, 18.4838466644287, 18.7038478851318, 18.9238471984863, 19.1438484191895, 19.3638477325439, 19.5838470458984, 19.8038482666016, 20.0238475799561, 20.2438468933105, 20.4638481140137, 20.6838474273682, 20.9038467407227, 21.1238479614258, 21.3438472747803, 21.5638465881348, 21.7838478088379, 22.0038471221924, 22.2238464355469, 22.44384765625, 22.6638469696045, 22.883846282959, 23.1038475036621, 23.3238487243652, 23.5438461303711, 23.7638473510742, 23.9838485717773, 24.2038478851318, 24.4238471984863, 24.6438484191895, 24.8638477325439, 25.0838470458984, 25.3038482666016, 25.5238475799561, 25.7438468933105, 25.9638481140137, 26.1838474273682, 26.4038467407227, 26.6238479614258, 26.8438472747803, 27.0638465881348, 27.2838478088379, 27.5038471221924, 27.7238464355469, 27.94384765625, 28.1638469696045, 28.383846282959, 28.6038475036621, 28.8238468170166, 29.0438480377197, 29.2638473510742, 29.4838485717773, 29.7038478851318, 29.9238471984863, 30.1438484191895, 30.3638477325439, 30.5838470458984, 30.8038482666016, 31.0238475799561, 31.2438468933105, 31.4638481140137, 31.6838474273682, 31.9038467407227, 32.1238479614258, 32.3438491821289, 32.5638465881348, 32.7838478088379, 33.003849029541, 33.2238464355469, 33.44384765625, 33.6638488769531, 33.883846282959, 34.1038475036621, 34.3238487243652, 34.5438461303711, 34.7638473510742, 34.9838485717773, 35.2038459777832, 35.4238471984863, 35.6438484191895, 35.8638458251953, 36.0838470458984, 36.3038482666016, 36.5238456726074, 36.7438468933105, 36.9638481140137, 37.1838455200195, 37.4038467407227198 </ncml:values>199 </ncml:variable>200 </ncml:netcdf>201 }}}202 In order to save the changes in a new netcdf file, we can use toolsUI.203 {{{204 java -cp /software/meteo/jar/toolsUI-4.6.5.jar ucar.nc2.write.Nccopy --input rlat_new.ncml --output tas_new.nc --format netcdf4_classic -d 4 -sh205 }}}