| 53 | |
| 54 | == Overview about the Data Files == |
| 55 | The files are stored at /data/slmet/slmet111/met_data/ecmwf/era5/netcdf4/2017/ |
| 56 | |
| 57 | The Files cover a period of time for two month: June and August 2017 in 1 h steps. |
| 58 | Example of a filename: 2017061516_ml.nc (YYYYMMDDHH) |
| 59 | |
| 60 | Some interesting variables stored in the *ml-files: |
| 61 | cc (1 x 137 x 601 x 1200): Fraction of cloud cover |
| 62 | ciwc (1 x 137 x 601 x 1200): Specific cloud ice water content |
| 63 | clwc (1 x 137 x 601 x 1200): Specific cloud liquid water content |
| 64 | d (1 x 137 x 601 x 1200): divergence_of_wind |
| 65 | o3 (1 x 137 x 601 x 1200): Ozone mass mixing ratio |
| 66 | q (1 x 137 x 601 x 1200): Specific humidity |
| 67 | t (1 x 137 x 601 x 1200): Temperature |
| 68 | u (1 x 137 x 601 x 1200): U component of wind (eastward wind) |
| 69 | v (1 x 137 x 601 x 1200): V component of wind (northward wind) |
| 70 | w (1 x 137 x 601 x 1200): Vertical velocity |
| 71 | vo (1 x 137 x 601 x 1200): Vorticity (relative) |
| 72 | |
| 73 | Variables related to coordinates:\\ |
| 74 | lat (601): latitude (degrees north), ranging from 90 to -90 |
| 75 | lon (1200): longitude (degrees east), ranging from 0 to 359.7 |
| 76 | lev, lev_2 (137): hybrid_sigma_pressure, ranging from 1 to 137 (137 is ground level!) |
| 77 | |
| 78 | Calculation of Coordinates:\\ |
| 79 | ParaView does not understand the original coordinates (lat, lon, lev_2) this way. Therefore, these must be converted into a "structured grid" data structure. See the "generate_coordinates.py" script. |
| 80 | Here also a conversion to Cartesian coordinates takes place essentially via: |
| 81 | {{{ |
| 82 | #!python |
| 83 | height = (137.0 - levIn[i])*.5 + 150 |
| 84 | x = height * np.cos(lat*3.14/180)*np.cos(lon*3.14/180*1.002) |
| 85 | y = height * np.cos(lat*3.14/180)*np.sin(lon*3.14/180*1.002) |
| 86 | z = height * np.sin(lat*3.14/180) |
| 87 | }}} |
| 88 | The generated coordinates are stored in the new created file "coordinates.h5". |
| 89 | ATTENTION: ParaView can read this "structured grid", but cannot volume-render, as volume rendering only works good for image data. Therefore, the filter "Resample to Image" must be applied to the reader in ParaView! |
| 90 | |
| 91 | Create XDMF files:\\ |
| 92 | The hdf5 files are read via an xdmf reader. To enable this, an xdmf file must be created. The script "make_xdmf.py" does this. The script essentially scans the directory where the files are located and gets the names of all files for one month (the month is fixed in the script). |
| 93 | Variables that can be read into ParaView later are noted in the script via: |
| 94 | {{{ |
| 95 | #!python |
| 96 | scalars=["cc", "ciwc", "clwc", "q", "d", "vo", "o3", "w"]] |
| 97 | }}} |
| 98 | The name of the xdmf-output file is structuredgrid_201709.xdmf. |
| 99 | |
| 100 | == !ParaView == |
| 101 | === Loading the necessary modules === |
| 102 | The modules can be found out with "module spider ParaView/5.5.0". |
| 103 | Load modules e.g. with: |
| 104 | {{{ |
| 105 | #!bash |
| 106 | module load Stages/2018a Intel/2018.2.199-GCC-5.5.0 ParaStationMPI/5.2.1-1 ParaView/5.5.0 |
| 107 | }}} |
| 108 | |
| 109 | === ParaView GUI === |
| 110 | First load the modules, then start !ParaView GUI |
| 111 | {{{ |
| 112 | #!bash |
| 113 | vglrun paraview |
| 114 | }}} |
| 115 | The GUI is well suited to prototype the scene, i.e. to define the visualization pipeline with its parameters, i.e. the filters, the color tables and the camera positions. However, for various reasons it makes sense to script the visualization in !ParaView: |
| 116 | - In the script all parameters are recorded in text form |
| 117 | - Loading !ParaView GUI states sometimes does not work |
| 118 | - !ParaView has a memory leak, so after a few render steps you have to quit !ParaView and restart it at the aborted location. This can be automated using a script. |
| 119 | |
| 120 | |
| 121 | === From GUI to Script === |
| 122 | How-To transfer pipeline parameters from GUI to script:\\ |
| 123 | In the !ParaView-GUI, start a Python trace by Tools->Start Trace. |
| 124 | Then create the pipeline you want. The corresponding Python commands are displayed in the trace. These can be transferred into a script with copy & paste. |
| 125 | |
| 126 | How-To transfer colormaps from GUI to script:\\ |
| 127 | Once you have designed a good colormap, you can save it as a preset. This preset can then be renamed and saved to disk as *.json file. |
| 128 | Since a different colormap makes sense for each variable, in the example the naming scheme for colormap files is "stein_''variable''.json", e.g. "stein_vo.json" for the vorticity. This naming scheme is expected in the Python scripts, which among other things load the color tables |
| 129 | |
| 130 | How-To transfer camera parameter from GUI to script:\\ |
| 131 | You can save four camera positions in !ParaView. Click on the camera icon ("Adjust Camera"), then "configure", then "Assign current view". The camera positions can be saved in an XML file via "export" and can later be read in and used in the Python script e.g. with: |
| 132 | {{{ |
| 133 | #!python |
| 134 | import xml.etree.ElementTree as ET |
| 135 | from paraview.simple import * |
| 136 | def assignCameraParameters(root, camera, camIdx): |
| 137 | camera.SetPosition(float(root[camIdx-1][1][0][0][0][0].attrib['value']), float(root[camIdx-1][1][0][0][0][1].attrib['value']), float(root[camIdx-1][1][0][0][0][2].attrib['value'])) |
| 138 | camera.SetFocalPoint(float(root[camIdx-1][1][0][0][1][0].attrib['value']), float(root[camIdx-1][1][0][0][1][1].attrib['value']), float(root[camIdx-1][1][0][0][1][2].attrib['value'])) |
| 139 | camera.SetViewUp(float(root[camIdx-1][1][0][0][2][0].attrib['value']), float(root[camIdx-1][1][0][0][2][1].attrib['value']), float(root[camIdx-1][1][0][0][2][2].attrib['value'])) |
| 140 | camera.SetParallelScale(float(root[camIdx-1][1][0][0][6][0].attrib['value'])) |
| 141 | |
| 142 | tree = ET.parse('camera_' + attribute + '.pvcvbc') |
| 143 | root = tree.getroot() |
| 144 | camera = GetActiveCamera() |
| 145 | assignCameraParameters(root, camera, 1) |
| 146 | }}} |
| 147 | |
| 148 | |
| 149 | |