[25834] | 1 | Index: ../trunk-jpl/src/m/contrib/defleurian/paraview/exportVTK.py
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/src/m/contrib/defleurian/paraview/exportVTK.py (revision 25482)
|
---|
| 4 | +++ ../trunk-jpl/src/m/contrib/defleurian/paraview/exportVTK.py (revision 25483)
|
---|
| 5 | @@ -142,55 +142,56 @@
|
---|
| 6 | raise BadDimension('exportVTK does not support dimension {}'.format(dim))
|
---|
| 7 |
|
---|
| 8 | if 'clipping' in kwargs.keys():
|
---|
| 9 | - # first get the boundaries and check them
|
---|
| 10 | - [Xmin, Xmax, Ymin, Ymax] = kwargs['clipping']
|
---|
| 11 | - if Xmin > Xmax:
|
---|
| 12 | - raise ClipError('Xmax ({}) should be larger than Xmin ({})'.format(Xmax, Xmin))
|
---|
| 13 | - if Ymin > Ymax:
|
---|
| 14 | - raise ClipError('Ymax ({}) should be larger than Ymin ({})'.format(Ymax, Ymin))
|
---|
| 15 | - if Xmin > np.nanmax(points[:, 0]) or Xmax < np.nanmin(points[:, 0]):
|
---|
| 16 | - raise ClipError('Your X boundaries [{}, {}] are outside of the model domain [{},{}]'.format(Xmin, Xmax, np.nanmin(points[:, 0]), np.nanmax(points[:, 0])))
|
---|
| 17 | - if Ymin > np.nanmax(points[:, 1]) or Ymax < np.nanmin(points[:, 1]):
|
---|
| 18 | - raise ClipError('Your Y boundaries [{}, {}] are outside of the model domain [{},{}]'.format(Ymin, Ymax, np.nanmin(points[:, 1]), np.nanmax(points[:, 1])))
|
---|
| 19 | + if kwargs['clipping'] is not None:
|
---|
| 20 | + # first get the boundaries and check them
|
---|
| 21 | + [Xmin, Xmax, Ymin, Ymax] = kwargs['clipping']
|
---|
| 22 | + if Xmin > Xmax:
|
---|
| 23 | + raise ClipError('Xmax ({}) should be larger than Xmin ({})'.format(Xmax, Xmin))
|
---|
| 24 | + if Ymin > Ymax:
|
---|
| 25 | + raise ClipError('Ymax ({}) should be larger than Ymin ({})'.format(Ymax, Ymin))
|
---|
| 26 | + if Xmin > np.nanmax(points[:, 0]) or Xmax < np.nanmin(points[:, 0]):
|
---|
| 27 | + raise ClipError('Your X boundaries [{}, {}] are outside of the model domain [{},{}]'.format(Xmin, Xmax, np.nanmin(points[:, 0]), np.nanmax(points[:, 0])))
|
---|
| 28 | + if Ymin > np.nanmax(points[:, 1]) or Ymax < np.nanmin(points[:, 1]):
|
---|
| 29 | + raise ClipError('Your Y boundaries [{}, {}] are outside of the model domain [{},{}]'.format(Ymin, Ymax, np.nanmin(points[:, 1]), np.nanmax(points[:, 1])))
|
---|
| 30 |
|
---|
| 31 | - #boundaries should be fine lets do stuff
|
---|
| 32 | - InX = np.where(np.logical_and(points[:, 0] >= Xmin, points[:, 0] <= Xmax))
|
---|
| 33 | - InY = np.where(np.logical_and(points[:, 1] >= Ymin, points[:, 1] <= Ymax))
|
---|
| 34 | + #boundaries should be fine lets do stuff
|
---|
| 35 | + InX = np.where(np.logical_and(points[:, 0] >= Xmin, points[:, 0] <= Xmax))
|
---|
| 36 | + InY = np.where(np.logical_and(points[:, 1] >= Ymin, points[:, 1] <= Ymax))
|
---|
| 37 |
|
---|
| 38 | - Isinside = np.zeros(np.shape(points)[0], dtype=bool)
|
---|
| 39 | - clip_convert_index = np.nan * np.ones(np.shape(points)[0])
|
---|
| 40 | + Isinside = np.zeros(np.shape(points)[0], dtype=bool)
|
---|
| 41 | + clip_convert_index = np.nan * np.ones(np.shape(points)[0])
|
---|
| 42 |
|
---|
| 43 | - Inclipping = np.intersect1d(InX, InY)
|
---|
| 44 | - Isinside[Inclipping] = True
|
---|
| 45 | - points = points[Inclipping, :]
|
---|
| 46 | - num_of_points = np.shape(points)[0]
|
---|
| 47 | + Inclipping = np.intersect1d(InX, InY)
|
---|
| 48 | + Isinside[Inclipping] = True
|
---|
| 49 | + points = points[Inclipping, :]
|
---|
| 50 | + num_of_points = np.shape(points)[0]
|
---|
| 51 |
|
---|
| 52 | - clipconnect = np.asarray([], dtype=int)
|
---|
| 53 | - for elt in connect:
|
---|
| 54 | - if set(elt).issubset(Inclipping):
|
---|
| 55 | - clipconnect = np.append(clipconnect, elt, axis=0)
|
---|
| 56 | + clipconnect = np.asarray([], dtype=int)
|
---|
| 57 | + for elt in connect:
|
---|
| 58 | + if set(elt).issubset(Inclipping):
|
---|
| 59 | + clipconnect = np.append(clipconnect, elt, axis=0)
|
---|
| 60 |
|
---|
| 61 | - num_of_elt = int(np.size(clipconnect) / 3)
|
---|
| 62 | - connect = clipconnect.reshape(num_of_elt, 3)
|
---|
| 63 | + num_of_elt = int(np.size(clipconnect) / 3)
|
---|
| 64 | + connect = clipconnect.reshape(num_of_elt, 3)
|
---|
| 65 |
|
---|
| 66 | - clip_convert_index = np.asarray([[i, np.where(Inclipping == i)[0][0]] for i, val in enumerate(clip_convert_index) if any(Inclipping == i)])
|
---|
| 67 | - enveloppe_index = enveloppe_index[clip_convert_index[:, 0]]
|
---|
| 68 | - for elt in range(0, num_of_elt):
|
---|
| 69 | - try:
|
---|
| 70 | - connect[elt, 0] = clip_convert_index[np.where(clip_convert_index == connect[elt, 0])[0], 1][0]
|
---|
| 71 | - except IndexError:
|
---|
| 72 | - connect[elt, 0] = -1
|
---|
| 73 | - try:
|
---|
| 74 | - connect[elt, 1] = clip_convert_index[np.where(clip_convert_index == connect[elt, 1])[0], 1][0]
|
---|
| 75 | - except IndexError:
|
---|
| 76 | - connect[elt, 1] = -1
|
---|
| 77 | - try:
|
---|
| 78 | - connect[elt, 2] = clip_convert_index[np.where(clip_convert_index == connect[elt, 2])[0], 1][0]
|
---|
| 79 | - except IndexError:
|
---|
| 80 | - connect[elt, 2] = -1
|
---|
| 81 | + clip_convert_index = np.asarray([[i, np.where(Inclipping == i)[0][0]] for i, val in enumerate(clip_convert_index) if any(Inclipping == i)])
|
---|
| 82 | + enveloppe_index = enveloppe_index[clip_convert_index[:, 0]]
|
---|
| 83 | + for elt in range(0, num_of_elt):
|
---|
| 84 | + try:
|
---|
| 85 | + connect[elt, 0] = clip_convert_index[np.where(clip_convert_index == connect[elt, 0])[0], 1][0]
|
---|
| 86 | + except IndexError:
|
---|
| 87 | + connect[elt, 0] = -1
|
---|
| 88 | + try:
|
---|
| 89 | + connect[elt, 1] = clip_convert_index[np.where(clip_convert_index == connect[elt, 1])[0], 1][0]
|
---|
| 90 | + except IndexError:
|
---|
| 91 | + connect[elt, 1] = -1
|
---|
| 92 | + try:
|
---|
| 93 | + connect[elt, 2] = clip_convert_index[np.where(clip_convert_index == connect[elt, 2])[0], 1][0]
|
---|
| 94 | + except IndexError:
|
---|
| 95 | + connect[elt, 2] = -1
|
---|
| 96 |
|
---|
| 97 | - connect = connect[np.where(connect != -1)[0], :]
|
---|
| 98 | - num_of_elt = np.shape(connect)[0]
|
---|
| 99 | + connect = connect[np.where(connect != -1)[0], :]
|
---|
| 100 | + num_of_elt = np.shape(connect)[0]
|
---|
| 101 |
|
---|
| 102 | # }}}
|
---|
| 103 | # write header and mesh {{{
|
---|