gnome.outputters.json

JSON outputter Does not contain a schema for persistence yet

Module Contents

Classes

SpillJsonOutput

Class that outputs data on GNOME particles.

CurrentJsonOutput

Class that outputs GNOME current velocity results for each current mover

IceJsonOutput

Class that outputs GNOME ice property results for each ice mover

class gnome.outputters.json.SpillJsonOutput(_additional_data=None, **kwargs)

Bases: gnome.outputters.outputter.Outputter

Class that outputs data on GNOME particles. Following is the format for a particle - the data in <> are the results for each element.

{
    "certain": {
        "length":<LENGTH>
        "longitude": []
        "latitude": []
        "status_code": []
        "mass": []
        "spill_num":[]
    }
    "uncertain":{
        "length":<LENGTH>
        "longitude": []
        "latitude": []
        "status_code": []
        "mass": []
        "spill_num":[]
    }
    "step_num": <STEP_NUM>
    "timestamp": <TIMESTAMP>
}
Parameters:

current_movers (list) – A list or collection of current grid mover objects.

use super to pass optional kwargs to base class __init__ method

_schema
write_output(step_num, islast_step=False)

dump data in geojson format

class gnome.outputters.json.CurrentJsonOutput(current_movers, **kwargs)

Bases: gnome.outputters.outputter.Outputter

Class that outputs GNOME current velocity results for each current mover in a geojson format. The output is a collection of Features. Each Feature contains a Point object with associated properties. Following is the output format - the data in <> are the results for each element.

{
 "time_stamp": <TIME IN ISO FORMAT>,
 "step_num": <OUTPUT ASSOCIATED WITH THIS STEP NUMBER>,
 "feature_collections": {<mover_id>: {"type": "FeatureCollection",
                                      "features": [{"type": "Feature",
                                                    "id": <PARTICLE_ID>,
                                                    "properties": {"velocity": [u, v]
                                                                   },
                                                    "geometry": {"type": "Point",
                                                                 "coordinates": [<LONG>, <LAT>]
                                                                 },
                                                },
                                                ...
                                               ],
                                  },
                     ...
                     }
}
Parameters:

current_movers (list) – A list or collection of current grid mover objects.

use super to pass optional kwargs to base class __init__ method

_schema
write_output(step_num, islast_step=False)

dump data in geojson format

get_rounded_velocities(velocities)
get_unique_velocities(velocities)

In order to make numpy perform this function fast, we will use a contiguous structured array using a view of a void type that joins the whole row into a single item.

get_matching_velocities(velocities, v)
current_movers_to_dict()

a dict containing ‘obj_type’ and ‘id’ for each object in list/collection

class gnome.outputters.json.IceJsonOutput(ice_movers, **kwargs)

Bases: gnome.outputters.outputter.Outputter

Class that outputs GNOME ice property results for each ice mover in a raw JSON format. The output contains a dict keyed by mover id. Each value item in the dict contains a list of feature data. Each feature item contains the ice fraction and thickness, and polyonal coordinate data. Following is the output format.

{
 "time_stamp": <TIME IN ISO FORMAT>,
 "step_num": <OUTPUT ASSOCIATED WITH THIS STEP NUMBER>,
 "feature_collections": {<mover_id>: [[<ICE_CONCENTRATION>,
                                       <ICE_THICKNESS>,
                                       [[<LONG>, <LAT>], ...],
                                       ],
                                      ...
                                      ],
                         ...
                         }
}
Parameters:

ice_movers (An ice_mover object or sequence of ice_mover objects.) – ice_movers associated with this outputter.

Use super to pass optional kwargs to base class __init__ method

_schema
clean_output_files()

this outputter doesn’t write any files

but this method needs to be here

write_output(step_num, islast_step=False)

dump data in geojson format

rewind()

remove previously written files