Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

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'

Release files for pfs2yaml 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pfs2yaml 0.1.0
File Size Uploaded
pfs2yaml-0.1.0.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pfs2yaml 0.1.0
File Interpreter ABI Platform
pfs2yaml-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.4 kB

Release files / pfs2yaml-0.1.0.tar.gz

Download URL pfs2yaml-0.1.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
52451e38aab9a82c69840c1c7a0d14f53515ef287538e20723a2b6229bffb930
BLAKE2b-256 checksum
How to use checksums
59518d28e21a1ce6cc62390ad8214f73b9da2fe425448e42ced9a12a5ca21729
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / pfs2yaml-0.1.0-py3-none-any.whl

Download URL pfs2yaml-0.1.0-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2ee6ab063f971c507279065e563c587440aafc2b95c1d71080c7db2c6f1b45f
BLAKE2b-256 checksum
How to use checksums
883b190eb1d96654f1f0132fa274da9108f9e0aecbcd36d7e6f8f362bfd8d75c
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page