Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Peril code grouping #20

Open
stufraser1 opened this issue Jul 29, 2021 · 5 comments
Open

Peril code grouping #20

stufraser1 opened this issue Jul 29, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@stufraser1
Copy link
Collaborator

Explore whether adjustment to mapping file can address problems found in testing, with handling grouped peril codes in one model format (AIR) and separate peril codes in another (OED).
Documentation should highlight this as a known issue for this translation.

@stufraser1
Copy link
Collaborator Author

@tristanlloyd @benhayes21 Please could you add an example of the codes and the transformation direction requiring code splitting / direction requiring combination for this issue, to assist understanding the logic required to implement it in the mapping file. Thanks

@stufraser1
Copy link
Collaborator Author

stufraser1 commented Sep 22, 2021

Previous feedback from Tristan:
(This example is closely related to, but not exactly the same as, splitting a grouped peril code to a string of peril codes, so I may be conflating two issues)

Trying to implement something like; transformation: 1 when: search(LayerPeril,‘PWH’) to split an AIR peril string like ‘PWH+PSH+PPH’ etc., to create separate peril columns with 1 or blanks (as required in our Sequel Impact Import).
The string manipulation functions implemented in the converter ONLY work for the transformation: part, and can’t be used in the when: clauses.
Can only put the search() function in the transformation: part, to return TRUE / FALSE.
Then needed to post-process the resulting file to convert to 1 / ’’, [Couldn’t nest the search() within a replace(), i.e., replace(search(LayerPeril,‘PWH’),’TRUE’, 1,’FALSE’,’’) ].

@stufraser1
Copy link
Collaborator Author

The best reference is https://docs.air-worldwide.com/Database/CEDE/9.0/topic137.html
Grouped peril code: PWS equates to PWH+PSH Windstorm
PEQ equates to PES+PFF+PTS+PLS+PSL All Earthquake perils
PFH equates to TS PFL+PSH Inland and Coastal Flood

Is the best way to deal with this, to include the original and destination in the peril code listing, i.e. transform the grouped code to string in the same way as we transform a single code to a single code (is any other logic actually needed?

@OmegaDroid
Copy link
Contributor

Spliting these into multiple transformations is the way to go here, something like

transformation: 1 
when: search(LayerPeril,‘PWH’) 

is correct, is this not working?

The reason this wouldn't work

replace(search(LayerPeril,‘PWH’),’TRUE’, 1,’FALSE’,’’)

is that the first argument to replace must be a string and search returns a boolean.

@stufraser1
Copy link
Collaborator Author

stufraser1 commented Sep 30, 2021

Running this on a basic test does not appear to work as expected. Requires tests to confirm correct structuring of transformation using multiple where clauses, and documentation of how to perform these types of conditional statements with clear examples.
Per #27

Issues found in running tests using the one-way-transformation:

  • Using 'tab' to indent the where: clause, returns error: found character '\t' that cannot start any token
    in "/Users/stufraser/OEDtransform/examples/one-way-transformation/A-B.yaml"

  • Using where: b >= 10 return error: Expecting: {'GT', 'IS', 'PLUS', '__ANON_0', 'STAR', 'AND', 'MINUS', '__ANON_2', 'SLASH', 'GTE', 'LT', '__ANON_1', 'OR', 'LTE'}

  • Using where: b = 10 return error: Expecting: {'GT', 'IS', 'PLUS', '__ANON_0', 'STAR', 'AND', 'MINUS', '__ANON_2', 'SLASH', 'GTE', 'LT', '__ANON_1', 'OR', 'LTE'}

  • Using where: b == 10 return error: Expecting: {'GT', 'IS', 'PLUS', '__ANON_0', 'STAR', 'AND', 'MINUS', '__ANON_2', 'SLASH', 'GTE', 'LT', '__ANON_1', 'OR', 'LTE'}

  • Using where: b GTE 10 return error: Expecting: {'GT', 'IS', 'PLUS', '__ANON_0', 'STAR', 'AND', 'MINUS', '__ANON_2', 'SLASH', 'GTE', 'LT', '__ANON_1', 'OR', 'LTE'}

    • Using where: b IS 10 return error: Expecting: {'GT', 'IS', 'PLUS', '__ANON_0', 'STAR', 'AND', 'MINUS', '__ANON_2', 'SLASH', 'GTE', 'LT', '__ANON_1', 'OR', 'LTE'}
  • Using when: b is not in [10] works but is not as intuitive as using where: b <> 10, for example

Running the following, the transformation succeeds with no error, but only the 1st transformation is completed; second one is blank.
- transformation: b + 10
when: b is not in [10]
- transformation: 99
when: b is 10

Running the following, the transformation succeeds with no error, but all values in d return 99
- transformation: 99
when: b is 10
- transformation: b + 10
when: b is not in [10]

@stufraser1 stufraser1 added the enhancement New feature or request label Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants