fabiencasenave commited on
Commit
9f2e79e
·
verified ·
1 Parent(s): 134a8cd

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +32 -14
README.md CHANGED
@@ -1281,28 +1281,46 @@ Mesh objects included in samples follow the [CGNS](https://cgns.github.io/) stan
1281
 
1282
  Example of commands:
1283
  ```python
1284
- import pickle
1285
  from datasets import load_dataset
1286
  from plaid.containers.sample import Sample
 
1287
 
1288
  # Load the dataset
1289
- dataset = load_dataset("chanel/dataset", split="all_samples")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1290
 
1291
- # Get the first sample of the first split
1292
- split_names = list(dataset.description["split"].keys())
1293
- ids_split_0 = dataset.description["split"]['train_8']
1294
- sample_0_split_0 = dataset[ids_split_0[0]]["sample"]
1295
- plaid_sample = Sample.model_validate(pickle.loads(sample_0_split_0))
1296
- print("type(plaid_sample) =", type(plaid_sample))
1297
 
1298
- print("plaid_sample =", plaid_sample)
 
 
1299
 
1300
- # Get a field from the sample
1301
- field_names = plaid_sample.get_field_names()
1302
- field = plaid_sample.get_field(field_names[0])
1303
- print("field_names[0] =", field_names[0])
1304
 
1305
- print("field.shape =", field.shape)
 
 
 
 
1306
  ```
1307
 
1308
  ## Dataset Details
 
1281
 
1282
  Example of commands:
1283
  ```python
 
1284
  from datasets import load_dataset
1285
  from plaid.containers.sample import Sample
1286
+ import pickle
1287
 
1288
  # Load the dataset
1289
+ hf_dataset = load_dataset("PLAID-datasets/Tensile2d", split="all_samples")
1290
+
1291
+ # Get split ids
1292
+ ids_train = hf_dataset.description["split"]['train_500']
1293
+ ids_test = hf_dataset.description["split"]['test']
1294
+
1295
+ # Get inputs/outputs names
1296
+ in_scalars_names = hf_dataset.description["in_scalars_names"]
1297
+ out_fields_names = hf_dataset.description["out_fields_names"]
1298
+
1299
+ # Get samples
1300
+ sample = Sample.model_validate(pickle.loads(hf_dataset[ids_train[0]]["sample"]))
1301
+ sample_2 = Sample.model_validate(pickle.loads(hf_dataset[ids_test[0]]["sample"]))
1302
+
1303
+ # Examples data retrievals
1304
+ # inputs
1305
+ nodes = sample.get_nodes()
1306
+ elements = sample.get_elements()
1307
+ nodal_tags = sample.get_nodal_tags()
1308
 
1309
+ for sn in ['P', 'p1', 'p2', 'p3', 'p4', 'p5']:
1310
+ scalar = sample.get_scalar(sn)
 
 
 
 
1311
 
1312
+ # outputs
1313
+ for fn in ['U1', 'U2', 'q', 'sig11', 'sig22', 'sig12']:
1314
+ field = sample.get_field(fn)
1315
 
1316
+ for sn in ['max_von_mises', 'max_q', 'max_U2_top', 'max_sig22_top']:
1317
+ scalar = sample.get_scalar(sn)
 
 
1318
 
1319
+ # Get the mesh and convert it to Muscat
1320
+ from Muscat.Bridges import CGNSBridge
1321
+ CGNS_tree = sample.get_mesh()
1322
+ mesh = CGNSBridge.CGNSToMesh(CGNS_tree)
1323
+ print(mesh)
1324
  ```
1325
 
1326
  ## Dataset Details