kmltools module of utility functions¶
This describes new tools added in Clawpack 5.2.1.
Documentation auto-generated from the module docstrings¶
kmltools module: $CLAW/geoclaw/src/python/geoclaw/kmltools.py
Tools to make kml files to overlay on Google Earth. Note that color is in KML format, BGR with 2 hex digits for each, e.g.
FF0000 is blue, 00FF00 is green, 0000FF is red, 00FF00 is yellow.
Actually it’s an 8 hex digit number, where the first two digits are transparency, but in this module these default to ‘FF’ (but you can specify the full 8 digits if you want it transparent).
Functions: |
|
---|
-
clawpack.geoclaw.kmltools.
box2kml
(xy, fname=None, name='box', color='FF0000', width=3, verbose=True)¶ Make a KML box with default color blue.
Inputs: - xy a tuple ((x1,x2),(y1,y2)) (preferred)
- or (x1,x2,y1,y2) (for backward compatibility)
- fname (str) name of resulting kml file
- name (str) name to appear in box on Google Earth
- color (str) Color in format aabbggrr
- width (str) line width
- verbose (bool) - If True, print out info
-
clawpack.geoclaw.kmltools.
deg2dms
(dy)¶ Convert decimal degrees to tuple (degrees, minutes, seconds)
-
clawpack.geoclaw.kmltools.
dtopo2kml
(dtopo_file_name, dtopo_type, color='8888FF')¶ Create a kml file putting a box around the region covered by a dtopofile. Color is pink by default.
-
clawpack.geoclaw.kmltools.
f2s
(x, num_digits=6)¶ Convert float to string in fixed point notation with at most num_digits digits of precision and trailing zeros removed, for printing nicely in kml description boxes.
-
clawpack.geoclaw.kmltools.
gauges2kml
(rundata=None, fname='gauges.kml', verbose=True)¶ Create a KML marker for each gauge specified for a GeoClaw run.
Inputs: rundata - an object of class ClawRunData or None
If rundata==None, try to create based on executing function setrun from the setrun.py file in the current directory.
fname (str) - resulting kml file.
verbose (bool) - If True, print out info about each region found
Example: >>> from clawpack.geoclaw import kmltools >>> kmltools.gauges2kml()
is equivalent to:
>>> from clawpack.geoclaw import kmltools >>> from setrun import setrun >>> rundata = setrun() >>> kmltools.gauges2kml(rundata)
By default this creates a file named gauges.kml that can be opened in Google Earth.
-
clawpack.geoclaw.kmltools.
kml_timespan
(t1, t2, event_time=None, tz=None, tscale=1)¶ Create time strings necessary for sliders in Google Earth. The time span will cover time [t1,t2], with the start of the event given by event_time.
[t1,t2] : time span,
event_time : Start of event in UTC : [Y,M,D,H,M,S], e.g. [2010,2,27,3,34,0] tz : time zone offset to UTC. e.g. +3 for Chile; -9 for Japan.
Time span element looks like
<TimeSpan> <begin>2010-02-27T06:34:00+03:00</begin> <end>2010-02-27T07:04:00+03:00</end> </TimeSpan>
As for how well this handles Daylight Savings time, here is what the documentation on the Python ‘time’ module has to say :
“DST is Daylight Saving Time, an adjustment of the timezone by (usually) one hour during part of the year. DST rules are magic (determined by local law) and can change from year to year. The C library has a table containing the local rules (often it is read from a system file for flexibility) and is the only source of True Wisdom in this respect.”
-
clawpack.geoclaw.kmltools.
line2kml
(xy, fname='line.kml', name='line', color='00FFFF', width=3, verbose=True)¶ Make a KML line with default color yellow.
Inputs: - xy a tuple ((x1,x2),(y1,y2)) (preferred)
- or (x1,x2,y1,y2) (for backward compatibility)
- fname (str) name of resulting kml file
- name (str) name to appear on line on Google Earth
- color (str) Color in format aabbggrr
- width (str) line width
- verbose (bool) - If True, print out info
-
clawpack.geoclaw.kmltools.
make_input_data_kmls
(rundata)¶ Produce kml files for the computational domain, all gauges and regions specified, and all topo and dtopo files specified in rundata. This can be used, e.g. by adding the lines
from clawpack.geoclaw import kmltools kmltools.make_input_data_kmls(rundata)to the end of a setrun.py file so that make data will generate all kml files in addition to the *.data files.
-
clawpack.geoclaw.kmltools.
poly2kml
(xy, fname=None, name='poly', color='00FF00', width=3, verbose=True)¶ Make a KML polygon with default color blue.
Inputs: - xy a tuple (x,y) where x and y are lists of vertices
- fname (str) name of resulting kml file
- name (str) name to appear in box on Google Earth
- color (str) Color in format aabbggrr
- width (str) line width
- verbose (bool) - If True, print out info
-
clawpack.geoclaw.kmltools.
quad2kml
(xy, fname=None, name='quad', color='FF0000', width=3, verbose=True)¶ Make a KML quadrilateral with default color blue.
Inputs: - xy a tuple ((x1,x2,x3,x4),(y1,y2,y3,y4)) (preferred)
- or (x1,x2,y1,y2,x3,y3,x4,y4) (for backward compatibility)
- fname (str) name of resulting kml file
- name (str) name to appear in box on Google Earth
- color (str) Color in format aabbggrr
- width (str) line width
- verbose (bool) - If True, print out info
-
clawpack.geoclaw.kmltools.
regions2kml
(rundata=None, fname='regions.kml', verbose=True, combined=True)¶ Create a KML box for each AMR region specified for a GeoClaw run.
Inputs: rundata - an object of class ClawRunData or None
If rundata==None, try to create based on executing function setrun from the setrun.py file in the current directory.
fname (str) - resulting kml file.
verbose (bool) - If True, print out info about each region found
combined (bool) - If True, combine into single kml file with name given by fname. This is the default. If False, fname is ignored and individual files are created for each region with names are Domain.kml, Region00.kml, etc. These will show up separately in GoogleEarth so they can be turned on or off individually.
First create a box for the entire domain (in red) and then a box for each region (in white).
Example: >>> from clawpack.geoclaw import kmltools >>> kmltools.regions2kml()
is equivalent to:
>>> from clawpack.geoclaw import kmltools >>> from setrun import setrun >>> rundata = setrun() >>> kmltools.regions2kml(rundata)
By default this creates a file named regions.kml that can be opened in Google Earth.
-
clawpack.geoclaw.kmltools.
topo2kml
(topo_file_name, topo_type, color='00FF00')¶ Create a kml file putting a box around the region covered by a topofile. Color is green by default.