fabiencasenave commited on
Commit
2ad883e
·
verified ·
1 Parent(s): 0bb2e22

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +19 -15
README.md CHANGED
@@ -465,32 +465,36 @@ Mesh objects included in samples follow the [CGNS](https://cgns.github.io/) stan
465
 
466
  Example of commands:
467
  ```python
468
- import pickle
469
  from datasets import load_dataset
470
  from plaid.containers.sample import Sample
 
471
 
472
  # Load the dataset
473
- dataset = load_dataset("chanel/dataset", split="all_samples")
 
 
 
 
474
 
475
- # Get the first sample of the first split
476
- split_names = list(dataset.description["split"].keys())
477
- ids_split_0 = dataset.description["split"][split_names[0]]
478
- sample_0_split_0 = dataset[ids_split_0[0]]["sample"]
479
- plaid_sample = Sample.model_validate(pickle.loads(sample_0_split_0))
480
- print("type(plaid_sample) =", type(plaid_sample))
481
 
482
- print("plaid_sample =", plaid_sample)
 
 
483
 
484
- # Get a field from the sample
485
- field_names = plaid_sample.get_field_names()
486
- field = plaid_sample.get_field(field_names[0])
487
- print("field_names[0] =", field_names[0])
488
 
489
- print("field.shape =", field.shape)
 
490
 
491
  # Get the mesh and convert it to Muscat
492
  from Muscat.Bridges import CGNSBridge
493
- CGNS_tree = plaid_sample.get_mesh()
494
  mesh = CGNSBridge.CGNSToMesh(CGNS_tree)
495
  print(mesh)
496
  ```
 
465
 
466
  Example of commands:
467
  ```python
 
468
  from datasets import load_dataset
469
  from plaid.containers.sample import Sample
470
+ import pickle
471
 
472
  # Load the dataset
473
+ hf_dataset = load_dataset("PLAID-datasets/2D_profile", split="all_samples")
474
+
475
+ # Get split ids
476
+ ids_train = hf_dataset.description["split"]['train']
477
+ ids_test = hf_dataset.description["split"]['test']
478
 
479
+ # Get inputs/outputs names
480
+ in_scalars_names = hf_dataset.description["in_scalars_names"]['train']
481
+ out_fields_names = hf_dataset.description["out_fields_names"]['train']
 
 
 
482
 
483
+ # Get samples
484
+ sample = Sample.model_validate(pickle.loads(hf_dataset[ids_train[0]]["sample"]))
485
+ sample = Sample.model_validate(pickle.loads(hf_dataset[ids_test[0]]["sample"]))
486
 
487
+ # Examples data retrievals
488
+ nodes = sample.get_nodes()
489
+ elements = sample.get_elements()
490
+ nodal_tags = sample.get_nodal_tags())
491
 
492
+ for fn in ['Mach', 'Pressure', 'Velocity-x', 'Velocity-y']:
493
+ field = sample.get_field(fn)
494
 
495
  # Get the mesh and convert it to Muscat
496
  from Muscat.Bridges import CGNSBridge
497
+ CGNS_tree = sample.get_mesh()
498
  mesh = CGNSBridge.CGNSToMesh(CGNS_tree)
499
  print(mesh)
500
  ```