fabiencasenave commited on
Commit
6cbad9d
·
verified ·
1 Parent(s): 912ee97

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +26 -15
README.md CHANGED
@@ -2362,32 +2362,43 @@ Mesh objects included in samples follow the [CGNS](https://cgns.github.io/) stan
2362
 
2363
  Example of commands:
2364
  ```python
2365
- import pickle
2366
  from datasets import load_dataset
2367
  from plaid.containers.sample import Sample
 
2368
 
2369
  # Load the dataset
2370
- dataset = load_dataset("chanel/dataset", split="all_samples")
 
 
 
 
 
 
 
 
 
 
 
 
2371
 
2372
- # Get the first sample of the first split
2373
- split_names = list(dataset.description["split"].keys())
2374
- ids_split_0 = dataset.description["split"][split_names[1]]
2375
- sample_0_split_0 = dataset[ids_split_0[0]]["sample"]
2376
- plaid_sample = Sample.model_validate(pickle.loads(sample_0_split_0))
2377
- print("type(plaid_sample) =", type(plaid_sample))
2378
 
2379
- print("plaid_sample =", plaid_sample)
 
2380
 
2381
- # Get a field from the sample
2382
- field_names = plaid_sample.get_field_names()
2383
- field = plaid_sample.get_field(field_names[0])
2384
- print("field_names[0] =", field_names[0])
2385
 
2386
- print("field.shape =", field.shape)
2387
 
2388
  # Get the mesh and convert it to Muscat
2389
  from Muscat.Bridges import CGNSBridge
2390
- CGNS_tree = plaid_sample.get_mesh()
2391
  mesh = CGNSBridge.CGNSToMesh(CGNS_tree)
2392
  print(mesh)
2393
  ```
 
2362
 
2363
  Example of commands:
2364
  ```python
 
2365
  from datasets import load_dataset
2366
  from plaid.containers.sample import Sample
2367
+ import pickle
2368
 
2369
  # Load the dataset
2370
+ hf_dataset = load_dataset("PLAID-datasets/2D_Multiscale_Hyperelasticity", split="all_samples")
2371
+
2372
+ # Get split ids
2373
+ ids_train = hf_dataset.description["split"]['DOE_train']
2374
+ ids_test = hf_dataset.description["split"]['DOE_test']
2375
+
2376
+ # Get inputs/outputs names
2377
+ in_scalars_names = hf_dataset.description["in_scalars_names"]
2378
+ out_fields_names = hf_dataset.description["out_fields_names"]
2379
+
2380
+ # Get samples
2381
+ sample = Sample.model_validate(pickle.loads(hf_dataset[ids_train[0]]["sample"]))
2382
+ sample_2 = Sample.model_validate(pickle.loads(hf_dataset[ids_test[0]]["sample"]))
2383
 
2384
+ # Examples data retrievals
2385
+ # inputs
2386
+ nodes = sample.get_nodes()
2387
+ elements = sample.get_elements()
2388
+ nodal_tags = sample.get_nodal_tags()
 
2389
 
2390
+ for sn in ['C11', 'C12', 'C22']:
2391
+ scalar = sample.get_scalar(sn)
2392
 
2393
+ # outputs
2394
+ for fn in ['u1', 'u2', 'P11', 'P12', 'P22', 'P21', 'psi']:
2395
+ field = sample.get_field(fn)
 
2396
 
2397
+ effective_energy = sample.get_scalar("effective_energy")
2398
 
2399
  # Get the mesh and convert it to Muscat
2400
  from Muscat.Bridges import CGNSBridge
2401
+ CGNS_tree = sample.get_mesh()
2402
  mesh = CGNSBridge.CGNSToMesh(CGNS_tree)
2403
  print(mesh)
2404
  ```