A package that can convert DHI pfs files to yaml
Project description
PFS2YAML
Convert PFS files to YAML or python dictionary.
For a complete example of extracting coordinates of all sources see this notebook.
Installation
pip install https://github.com/DHI/pfs2yaml/archive/master.zip
Usage
Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 11:27:44) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pfs2yaml
>>> pfs = """
... [FemEngineHD]
... [DOMAIN]
... Touched = 1
... discretization = 2
... number_of_dimensions = 2
... number_of_meshes = 1
... file_name = |.\weird.mesh|
... type_of_reordering = 1
... number_of_domains = 16
... coordinate_type = 'PROJCS["UTM-32",GEOGCS["Unused",DATUM["UTM Projections",SPHEROID["WGS 1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",9],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0],UNIT["Meter",1]]'
... minimum_depth = -4.98911480069749
... datum_depth = 0.0
... vertical_mesh_type_overall = 1
... number_of_layers = 10
... z_sigma = -7.464212579701861
... vertical_mesh_type = 1
... layer_thickness = 0.1, 0.1, 0.1, 0.3, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1
... EndSect
... EndSect"""
>>> yml = pfs2yaml.pfs2yaml(pfs)
>>> print(yml)
---
FemEngineHD:
DOMAIN:
touched : 1
discretization : 2
number_of_dimensions : 2
number_of_meshes : 1
file_name : .\weird.mesh
type_of_reordering : 1
number_of_domains : 16
coordinate_type : 'PROJCS["UTM-32",GEOGCS["Unused",DATUM["UTM Projections",SPHEROID["WGS 1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",9],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0],UNIT["Meter",1]]'
minimum_depth : -4.98911480069749
datum_depth : 0.0
vertical_mesh_type_overall : 1
number_of_layers : 10
z_sigma : -7.464212579701861
vertical_mesh_type : 1
layer_thickness : [ 0.1, 0.1, 0.1, 0.3, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1]
>>> d = pfs2yaml.pfs2dict(pfs)
>>> d
{'FemEngineHD': {'DOMAIN': {'touched': 1, 'discretization': 2, 'number_of_dimensions': 2, 'number_of_meshes': 1, 'file_name': '.\\weird.mesh', 'type_of_reordering': 1, 'number_of_domains': 16, 'coordinate_type': 'PROJCS["UTM-32",GEOGCS["Unused",DATUM["UTM Projections",SPHEROID["WGS 1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",9],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0],UNIT["Meter",1]]', 'minimum_depth': -4.98911480069749, 'datum_depth': 0.0, 'vertical_mesh_type_overall': 1, 'number_of_layers': 10, 'z_sigma': -7.464212579701861, 'vertical_mesh_type': 1, 'layer_thickness': [0.1, 0.1, 0.1, 0.3, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1]}}}
>>> d = pfs2yaml.pfs2dict(pfs)
>>> d
>>> d["FemEngineHD"]["DOMAIN"]["layer_thickness"][3]
0.3
Command line interface
C:\>pfs2yaml --help
Usage: pfs2yaml [OPTIONS] INPUT [OUTPUT]
Convert PFS files to YAML
Output filename is optional.
Default value is input filename with .yml extension
Options:
--help Show this message and exit.
C:\>pfs2yaml Odense.m21fm
Writing YAML file: Odense.m21fm.yml
C:\>more Odense.m21fm.yml
---
! Created : 2018-01-16 10:31:3
! DLL id : C:\Program Files (x86)\DHI\2017\bin\x64\pfs2004.dll
! PFS version : Apr 4 2017 19:09:27
FemEngineHD:
DOMAIN:
touched : 1
discretization : 2
number_of_dimensions : 2
number_of_meshes : 1
file_name : .\Input\odense_rough.mesh
type_of_reordering : 0
number_of_domains : 16
coordinate_type : 'UTM-33'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pfs2yaml-0.1.0.tar.gz
(4.0 kB
view details)
Built Distribution
File details
Details for the file pfs2yaml-0.1.0.tar.gz
.
File metadata
- Download URL: pfs2yaml-0.1.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52451e38aab9a82c69840c1c7a0d14f53515ef287538e20723a2b6229bffb930 |
|
MD5 | 5208858775b8c4fac37a229e011e346c |
|
BLAKE2b-256 | 59518d28e21a1ce6cc62390ad8214f73b9da2fe425448e42ced9a12a5ca21729 |
File details
Details for the file pfs2yaml-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pfs2yaml-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2ee6ab063f971c507279065e563c587440aafc2b95c1d71080c7db2c6f1b45f |
|
MD5 | 6d8f4cde8885a5501e8d5aa916c5d8f8 |
|
BLAKE2b-256 | 883b190eb1d96654f1f0132fa274da9108f9e0aecbcd36d7e6f8f362bfd8d75c |