esheldon / pymangle

Simple code to read mangle masks, calculate ids and weights, and generate random points

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when reading shortened polygon descriptions

pmelchior opened this issue · comments

A full polygon description would read something like

polygon 18 ( 4 caps, 1 weight, 0 pixel, 0.042198885297204 str):

but there are shortened versions around there like

polygon 1 ( 4 caps, 1 weight ):

According to the Mangle manual, anything other than caps is optional:

The polygon specification also optionally includes the weight assigned to the polygon, the pixel in which the polygon is contained, and the area of the polygon in steradians. If these are not specified, the polygon will be assigned a default weight of 1 and a default pixel of 0.

However, when I try to read a file with shortened description, I get this error: Failed to read expected string in polygon: 'weight,' got 'weight'failed to read polygon 0

Can the reader be made more forgiving to tolerate these shortened descriptions, given that the optional parts are well meant to be, well, optional?

So pymangle only works with mangle files that have the pixels associated with them, so you need to run that mangle task first which adds the pixel and area.

Hmm, the description of the code says it works without pixelization but I don't know if that's ever been tested! Certainly not how I thought the code was supposed to be run.

the code does work without pixelization

This change will be straightforward but annoying to implement, because string operations in C are annoying :)

Note, however, that this means the polygons will not have an associated area.

I think this is OK for all the operations we currently support. New features would require knowing the area, in particular if we started supporting creation of masks. I looked into how the area is calculated in the original code and it would be extremely difficult to port that old fortran code.