-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathkmltools_module.html
617 lines (586 loc) · 38 KB
/
kmltools_module.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>kmltools module of utility functions — Clawpack 5.2.1 documentation</title>
<link rel="stylesheet" href="_static/flasky.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/base.css" type="text/css" />
<link rel="stylesheet" href="_static/layout.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css" />
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/language_data.js"></script>
<script async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="shortcut icon" href="_static/clawicon.ico"/>
<link rel="author" title="About these documents" href="about.html" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
</head><body>
<div id="main-wrapper" class="sphinx">
<div id="header-wrapper">
<section id="header">
<!-- <h1><a href="http://clawpack.org/">Clawpack</a></h1> -->
<h1><a href="http://clawpack.org/">Clawpack-5</a></h1>
<nav>
<ul>
<li>
<a href="contents.html">Docs</a>
</li>
<li>
<a href="installing.html">Install</a>
</li>
<li>
<a class="" href="http://clawpack.org/gallery/index.html">Gallery</a>
</li>
<li>
<a href="about.html">Citation</a>
</li>
<li>
<a class="active" href="http://github.com/clawpack">GitHub</a>
</li>
<li>
<a class="" href="community.html">Community</a>
</li>
<li>
<a class="" href="developers.html">Contribute</a>
</li>
</ul>
</nav>
</section>
<div class="decoration"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="contents.html">Clawpack 5.2.1 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="kmltools-module-of-utility-functions">
<span id="kmltools-module"></span><h1>kmltools module of utility functions<a class="headerlink" href="#kmltools-module-of-utility-functions" title="Permalink to this headline">¶</a></h1>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>This describes new tools to be added in Clawpack 5.2.1</p>
</div>
<div class="section" id="module-clawpack.geoclaw.kmltools">
<span id="documentation-auto-generated-from-the-module-docstrings"></span><h2>Documentation auto-generated from the module docstrings<a class="headerlink" href="#module-clawpack.geoclaw.kmltools" title="Permalink to this headline">¶</a></h2>
<p>kmltools module: $CLAW/geoclaw/src/python/geoclaw/kmltools.py</p>
<p>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.</p>
<blockquote>
<div><p>FF0000 is blue, 00FF00 is green, 0000FF is red, 00FF00 is yellow.</p>
</div></blockquote>
<p>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).</p>
<dl class="field-list simple">
<dt class="field-odd">Functions</dt>
<dd class="field-odd"><ul class="simple">
<li><p>deg2dms - convert decimal degrees to (degrees, minutes, seconds)</p></li>
<li><p>regions2kml - create a kml outline for each regions specified in setrun</p></li>
<li><p>box2kml - create a kml outline from a rectangular box</p></li>
<li><p>quad2kml - create a kml outline for an arbitrary quadrilateral</p></li>
<li><p>poly2kml - create a kml outline for an arbitrary polygon</p></li>
<li><p>line2kml - create a kml line connecting 2 points</p></li>
<li><p>gauges2kml - create a kml marker for each gauge specified in setrun</p></li>
<li><p>topo2kml - create a kml outline for each topo grid specified in setrun</p></li>
<li><p>dtopo2kml - create a kml outline for each dtopo grid specified in setrun</p></li>
<li><p>fgmax2kml - create a kml outline for each fgmax grid specified in setrun</p></li>
<li><p>fgout2kml - create a kml outline for each fgout grid specified in setrun</p></li>
<li><p>make_input_data_kmls - make kml files for many things specified in setrun</p></li>
<li><p>pcolorcells_for_kml - version of pcolormesh with appropriate dpi and size</p></li>
<li><p>png2kml - create kml file wrapping a png figure to be viewed on GE</p></li>
<li><p>kml_build_colorbar - create a colorbar to display on GE</p></li>
<li><p>topo2kmz - create kmz file showing onshore and offshore topography</p></li>
<li><p>kml_header - used internally</p></li>
<li><p>kml_footer - used internally</p></li>
<li><p>kml_region - used internally</p></li>
<li><p>kml_gauge - used internally</p></li>
<li><p>kml_png - used internally</p></li>
<li><p>strip_archive_extensions - strip off things like .tar or .gz</p></li>
</ul>
</dd>
</dl>
<dl class="function">
<dt id="clawpack.geoclaw.kmltools.box2kml">
<code class="sig-prename descclassname">clawpack.geoclaw.kmltools.</code><code class="sig-name descname">box2kml</code><span class="sig-paren">(</span><em class="sig-param">xy</em>, <em class="sig-param">fname=None</em>, <em class="sig-param">name='box'</em>, <em class="sig-param">color='FF0000'</em>, <em class="sig-param">width=3</em>, <em class="sig-param">verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#clawpack.geoclaw.kmltools.box2kml" title="Permalink to this definition">¶</a></dt>
<dd><p>Make a KML box with default color blue.</p>
<dl class="field-list simple">
<dt class="field-odd">Inputs</dt>
<dd class="field-odd"><ul class="simple">
<li><dl class="simple">
<dt><em>xy</em> a tuple ((x1,x2),(y1,y2)) (preferred) </dt><dd><p>or (x1,x2,y1,y2) (for backward compatibility)</p>
</dd>
</dl>
</li>
<li><p><em>fname</em> (str) name of resulting kml file</p></li>
<li><p><em>name</em> (str) name to appear in box on Google Earth</p></li>
<li><p><em>color</em> (str) Color in format aabbggrr</p></li>
<li><p><em>width</em> (str) line width</p></li>
<li><p><em>verbose</em> (bool) - If <em>True</em>, print out info</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="clawpack.geoclaw.kmltools.deg2dms">
<code class="sig-prename descclassname">clawpack.geoclaw.kmltools.</code><code class="sig-name descname">deg2dms</code><span class="sig-paren">(</span><em class="sig-param">dy</em><span class="sig-paren">)</span><a class="headerlink" href="#clawpack.geoclaw.kmltools.deg2dms" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert decimal degrees to tuple (degrees, minutes, seconds)</p>
</dd></dl>
<dl class="function">
<dt id="clawpack.geoclaw.kmltools.dtopo2kml">
<code class="sig-prename descclassname">clawpack.geoclaw.kmltools.</code><code class="sig-name descname">dtopo2kml</code><span class="sig-paren">(</span><em class="sig-param">dtopo_file_name</em>, <em class="sig-param">dtopo_type</em>, <em class="sig-param">color='8888FF'</em><span class="sig-paren">)</span><a class="headerlink" href="#clawpack.geoclaw.kmltools.dtopo2kml" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a kml file putting a box around the region covered by a dtopofile.
Color is pink by default.</p>
</dd></dl>
<dl class="function">
<dt id="clawpack.geoclaw.kmltools.f2s">
<code class="sig-prename descclassname">clawpack.geoclaw.kmltools.</code><code class="sig-name descname">f2s</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">num_digits=6</em><span class="sig-paren">)</span><a class="headerlink" href="#clawpack.geoclaw.kmltools.f2s" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert float to string in fixed point notation with at most
<em>num_digits</em> digits of precision and trailing zeros removed,
for printing nicely in kml description boxes.</p>
</dd></dl>
<dl class="function">
<dt id="clawpack.geoclaw.kmltools.fgmax2kml">
<code class="sig-prename descclassname">clawpack.geoclaw.kmltools.</code><code class="sig-name descname">fgmax2kml</code><span class="sig-paren">(</span><em class="sig-param">rundata=None</em>, <em class="sig-param">fname='fgmax_grids.kml'</em>, <em class="sig-param">verbose=True</em>, <em class="sig-param">combined=False</em><span class="sig-paren">)</span><a class="headerlink" href="#clawpack.geoclaw.kmltools.fgmax2kml" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a KML box for each fgmax grid specified for a GeoClaw run.</p>
<dl class="field-list">
<dt class="field-odd">Inputs</dt>
<dd class="field-odd"><ul>
<li><p><em>rundata</em> - an object of class <em>ClawRunData</em> or None</p>
<p>If <em>rundata==None</em>, try to create based on executing function <em>setrun</em>
from the <cite>setrun.py</cite> file in the current directory.</p>
</li>
<li><p><em>fname</em> (str) - resulting kml file.</p></li>
<li><p><em>verbose</em> (bool) - If <em>True</em>, print out info about each region found</p></li>
<li><p><em>combined</em> (bool) - If <em>True</em>, combine into single kml file with
name given by <em>fname</em>. NOT YET IMPLEMENTED.
If False, <em>fname</em> is ignored and individual files are created for
each fgmax grid.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="clawpack.geoclaw.kmltools.fgout2kml">
<code class="sig-prename descclassname">clawpack.geoclaw.kmltools.</code><code class="sig-name descname">fgout2kml</code><span class="sig-paren">(</span><em class="sig-param">rundata=None</em>, <em class="sig-param">fname='fgout_grids.kml'</em>, <em class="sig-param">verbose=True</em>, <em class="sig-param">combined=False</em><span class="sig-paren">)</span><a class="headerlink" href="#clawpack.geoclaw.kmltools.fgout2kml" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a KML box for each fgout grid specified for a GeoClaw run.</p>
<dl class="field-list">
<dt class="field-odd">Inputs</dt>
<dd class="field-odd"><ul>
<li><p><em>rundata</em> - an object of class <em>ClawRunData</em> or None</p>
<p>If <em>rundata==None</em>, try to create based on executing function <em>setrun</em>
from the <cite>setrun.py</cite> file in the current directory.</p>
</li>
<li><p><em>fname</em> (str) - resulting kml file.</p></li>
<li><p><em>verbose</em> (bool) - If <em>True</em>, print out info about each region found</p></li>
<li><p><em>combined</em> (bool) - If <em>True</em>, combine into single kml file with
name given by <em>fname</em>. NOT YET IMPLEMENTED.
If False, <em>fname</em> is ignored and individual files are created for
each fgout grid.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="clawpack.geoclaw.kmltools.gauges2kml">
<code class="sig-prename descclassname">clawpack.geoclaw.kmltools.</code><code class="sig-name descname">gauges2kml</code><span class="sig-paren">(</span><em class="sig-param">rundata=None</em>, <em class="sig-param">fname='gauges.kml'</em>, <em class="sig-param">verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#clawpack.geoclaw.kmltools.gauges2kml" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a KML marker for each gauge specified for a GeoClaw run.</p>
<dl class="field-list">
<dt class="field-odd">Inputs</dt>
<dd class="field-odd"><ul>
<li><p><em>rundata</em> - an object of class <em>ClawRunData</em> or None</p>
<p>If <em>rundata==None</em>, try to create based on executing function <em>setrun</em>
from the <cite>setrun.py</cite> file in the current directory.</p>
</li>
<li><p><em>fname</em> (str) - resulting kml file.</p></li>
<li><p><em>verbose</em> (bool) - If <em>True</em>, print out info about each region found</p></li>
</ul>
</dd>
<dt class="field-even">Example</dt>
<dd class="field-even"><div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">clawpack.geoclaw</span> <span class="kn">import</span> <span class="n">kmltools</span>
<span class="gp">>>> </span><span class="n">kmltools</span><span class="o">.</span><span class="n">gauges2kml</span><span class="p">()</span>
</pre></div>
</div>
</dd>
</dl>
<p>is equivalent to:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">clawpack.geoclaw</span> <span class="kn">import</span> <span class="n">kmltools</span>
<span class="gp">>>> </span><span class="kn">from</span> <span class="nn">setrun</span> <span class="kn">import</span> <span class="n">setrun</span>
<span class="gp">>>> </span><span class="n">rundata</span> <span class="o">=</span> <span class="n">setrun</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">kmltools</span><span class="o">.</span><span class="n">gauges2kml</span><span class="p">(</span><span class="n">rundata</span><span class="p">)</span>
</pre></div>
</div>
<p>By default this creates a file named <em>gauges.kml</em> that can be opened in
Google Earth.</p>
</dd></dl>
<dl class="function">
<dt id="clawpack.geoclaw.kmltools.kml_build_colorbar">
<code class="sig-prename descclassname">clawpack.geoclaw.kmltools.</code><code class="sig-name descname">kml_build_colorbar</code><span class="sig-paren">(</span><em class="sig-param">cb_filename</em>, <em class="sig-param">cmap</em>, <em class="sig-param">cmin=None</em>, <em class="sig-param">cmax=None</em>, <em class="sig-param">norm=None</em>, <em class="sig-param">label=None</em>, <em class="sig-param">title=None</em>, <em class="sig-param">extend='neither'</em>, <em class="sig-param">close_figs=True</em><span class="sig-paren">)</span><a class="headerlink" href="#clawpack.geoclaw.kmltools.kml_build_colorbar" title="Permalink to this definition">¶</a></dt>
<dd><p>Make a png file with a colorbar corresponding to cmap, norm.
cmin, cmax are used only if nrm is not provided.</p>
</dd></dl>
<dl class="function">
<dt id="clawpack.geoclaw.kmltools.kml_cb">
<code class="sig-prename descclassname">clawpack.geoclaw.kmltools.</code><code class="sig-name descname">kml_cb</code><span class="sig-paren">(</span><em class="sig-param">mapping</em><span class="sig-paren">)</span><a class="headerlink" href="#clawpack.geoclaw.kmltools.kml_cb" title="Permalink to this definition">¶</a></dt>
<dd><p>Create text for a colorbar png file overlay</p>
</dd></dl>
<dl class="function">
<dt id="clawpack.geoclaw.kmltools.kml_png">
<code class="sig-prename descclassname">clawpack.geoclaw.kmltools.</code><code class="sig-name descname">kml_png</code><span class="sig-paren">(</span><em class="sig-param">mapping</em><span class="sig-paren">)</span><a class="headerlink" href="#clawpack.geoclaw.kmltools.kml_png" title="Permalink to this definition">¶</a></dt>
<dd><p>Create text for a png file overlay</p>
</dd></dl>
<dl class="function">
<dt id="clawpack.geoclaw.kmltools.kml_timespan">
<code class="sig-prename descclassname">clawpack.geoclaw.kmltools.</code><code class="sig-name descname">kml_timespan</code><span class="sig-paren">(</span><em class="sig-param">t1</em>, <em class="sig-param">t2</em>, <em class="sig-param">event_time=None</em>, <em class="sig-param">tz=None</em>, <em class="sig-param">tscale=1</em><span class="sig-paren">)</span><a class="headerlink" href="#clawpack.geoclaw.kmltools.kml_timespan" title="Permalink to this definition">¶</a></dt>
<dd><p>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.</p>
<p>[t1,t2] : time span,</p>
<p>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.</p>
<p>Time span element looks like</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o"><</span><span class="n">TimeSpan</span><span class="o">></span>
<span class="o"><</span><span class="n">begin</span><span class="o">></span><span class="mi">2010</span><span class="o">-</span><span class="mi">02</span><span class="o">-</span><span class="mi">27</span><span class="n">T06</span><span class="p">:</span><span class="mi">34</span><span class="p">:</span><span class="mi">00</span><span class="o">+</span><span class="mi">03</span><span class="p">:</span><span class="mi">00</span><span class="o"></</span><span class="n">begin</span><span class="o">></span>
<span class="o"><</span><span class="n">end</span><span class="o">></span><span class="mi">2010</span><span class="o">-</span><span class="mi">02</span><span class="o">-</span><span class="mi">27</span><span class="n">T07</span><span class="p">:</span><span class="mi">04</span><span class="p">:</span><span class="mi">00</span><span class="o">+</span><span class="mi">03</span><span class="p">:</span><span class="mi">00</span><span class="o"></</span><span class="n">end</span><span class="o">></span>
<span class="o"></</span><span class="n">TimeSpan</span><span class="o">></span>
</pre></div>
</div>
<p>As for how well this handles Daylight Savings time, here is what the documentation
on the Python ‘time’ module has to say :</p>
<p>“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.”</p>
</dd></dl>
<dl class="function">
<dt id="clawpack.geoclaw.kmltools.line2kml">
<code class="sig-prename descclassname">clawpack.geoclaw.kmltools.</code><code class="sig-name descname">line2kml</code><span class="sig-paren">(</span><em class="sig-param">xy</em>, <em class="sig-param">fname='line.kml'</em>, <em class="sig-param">name='line'</em>, <em class="sig-param">color='00FFFF'</em>, <em class="sig-param">width=3</em>, <em class="sig-param">verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#clawpack.geoclaw.kmltools.line2kml" title="Permalink to this definition">¶</a></dt>
<dd><p>Make a KML line with default color yellow.</p>
<dl class="field-list simple">
<dt class="field-odd">Inputs</dt>
<dd class="field-odd"><ul class="simple">
<li><dl class="simple">
<dt><em>xy</em> a tuple ((x1,x2),(y1,y2)) (preferred) </dt><dd><p>or (x1,x2,y1,y2) (for backward compatibility)</p>
</dd>
</dl>
</li>
<li><p><em>fname</em> (str) name of resulting kml file</p></li>
<li><p><em>name</em> (str) name to appear on line on Google Earth</p></li>
<li><p><em>color</em> (str) Color in format aabbggrr</p></li>
<li><p><em>width</em> (str) line width</p></li>
<li><p><em>verbose</em> (bool) - If <em>True</em>, print out info</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="clawpack.geoclaw.kmltools.make_input_data_kmls">
<code class="sig-prename descclassname">clawpack.geoclaw.kmltools.</code><code class="sig-name descname">make_input_data_kmls</code><span class="sig-paren">(</span><em class="sig-param">rundata=None</em>, <em class="sig-param">combined=False</em><span class="sig-paren">)</span><a class="headerlink" href="#clawpack.geoclaw.kmltools.make_input_data_kmls" title="Permalink to this definition">¶</a></dt>
<dd><p>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</p>
<blockquote>
<div><p>from clawpack.geoclaw import kmltools
kmltools.make_input_data_kmls(rundata)</p>
</div></blockquote>
<p>to the end of a <cite>setrun.py</cite> file so that <cite>make data</cite> will generate all
kml files in addition to the <cite>*.data</cite> files.</p>
<p>Or set <em>rundata==None</em>, in which case it will try to generate rundata
based on executing function <em>setrun</em>
from the <cite>setrun.py</cite> file in the current directory.</p>
</dd></dl>
<dl class="function">
<dt id="clawpack.geoclaw.kmltools.pcolorcells_for_kml">
<code class="sig-prename descclassname">clawpack.geoclaw.kmltools.</code><code class="sig-name descname">pcolorcells_for_kml</code><span class="sig-paren">(</span><em class="sig-param">X</em>, <em class="sig-param">Y</em>, <em class="sig-param">Z</em>, <em class="sig-param">png_filename=None</em>, <em class="sig-param">dpc=2</em>, <em class="sig-param">max_inches=15.0</em>, <em class="sig-param">verbose=True</em>, <em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#clawpack.geoclaw.kmltools.pcolorcells_for_kml" title="Permalink to this definition">¶</a></dt>
<dd><p>Wraps pcolormesh in a way that a png file is created that can be viewed
on Google Earth with proper alignment and with sharp grid cell edges.
Works if X,Y are cell centers or edges, and X,Y can be 2d or 1d arrays.</p>
<p>X,Y,Z is the data to be plotted. It is assumed to be finite volume data
where Z[i,j] is a constant value over a grid cell.</p>
<p>Internally x,y are defined as 1d arrays since it is assumed the
grids are Cartesian.</p>
<p>If the length of the 1d arrays x and y match the dimensions of Z then
these are assumed to be cell center values. In this case the arrays
are expanded by one to obtain x_edge, y_edge as edge values,
as needed for proper alignment.</p>
<p>If the length of x,y is already one greater than the corresponding
dimension of Z, then it is assumed that these are already edge values.</p>
<p>If png_filename is not None then a png file is written with appropriate dpi.</p>
<p>dpc is the desired “dots per cell”, how many pixels to allot to each
to each grid cell. This should be an integer to avoid interpolation
between cells that smears out the cell boundaries in the png file.
Increasing this will give sharper boundaries but also larger files that
load more slowly.</p>
<p>max_inches is the desired size of the longer edge of the figure created.
This value is not very important unless you want to view the png file
on a screen outside of Google Earth. Internally the dimensions of the
figure <cite>x_inches</cite> and <cite>y_inches</cite> are determined to be consistent
with the value <cite>dpc</cite> specified and a reasonable value of <cite>dpi</cite> for the
png file, as described below.</p>
<p>Internally the value <cite>dpi</cite> (dots per inch) for the png file is
determined so that it is at least 16 and so that:</p>
<div class="system-message">
<p class="system-message-title">System Message: ERROR/3 (<span class="docutils literal">/Users/rjl/Downloads/clawpack-v5.9.0/geoclaw/src/python/geoclaw/kmltools.py:docstring of clawpack.geoclaw.kmltools.pcolorcells_for_kml</span>, line 36)</p>
<p>Unexpected indentation.</p>
</div>
<blockquote>
<div><p>dpi * x_inches = dcp * x_cells
dpi * y_inches = dcp * y_cells</p>
</div></blockquote>
<div class="system-message">
<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/Users/rjl/Downloads/clawpack-v5.9.0/geoclaw/src/python/geoclaw/kmltools.py:docstring of clawpack.geoclaw.kmltools.pcolorcells_for_kml</span>, line 38)</p>
<p>Block quote ends without a blank line; unexpected unindent.</p>
</div>
<p>where <cite>x_cells</cite>, <cite>y_cells</cite> are the number of cells in each direction.</p>
<p><cite>kwargs</cite> are passed to <cite>pcolormesh</cite>, e.g. <cite>cmap</cite> and <cite>norm</cite> are
generally specified.</p>
<p>This function returns <cite>fig, ax, png_extent, kml_dpi</cite> so the user can further
annotate the figure befor saving it as a png file, which should then
be done with:</p>
<div class="system-message">
<p class="system-message-title">System Message: ERROR/3 (<span class="docutils literal">/Users/rjl/Downloads/clawpack-v5.9.0/geoclaw/src/python/geoclaw/kmltools.py:docstring of clawpack.geoclaw.kmltools.pcolorcells_for_kml</span>, line 46)</p>
<p>Unexpected indentation.</p>
</div>
<blockquote>
<div><p>plt.savefig(png_filename, transparent=True, dpi=kml_dpi)</p>
</div></blockquote>
<div class="system-message">
<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/Users/rjl/Downloads/clawpack-v5.9.0/geoclaw/src/python/geoclaw/kmltools.py:docstring of clawpack.geoclaw.kmltools.pcolorcells_for_kml</span>, line 47)</p>
<p>Block quote ends without a blank line; unexpected unindent.</p>
</div>
<p>The <cite>png_extent</cite> is needed in construcing a kml file to display the
png file on Google Earth, e.g. using the function <cite>png2kml</cite> in this
module.</p>
</dd></dl>
<dl class="function">
<dt id="clawpack.geoclaw.kmltools.png2kml">
<code class="sig-prename descclassname">clawpack.geoclaw.kmltools.</code><code class="sig-name descname">png2kml</code><span class="sig-paren">(</span><em class="sig-param">extent</em>, <em class="sig-param">png_files</em>, <em class="sig-param">png_names=None</em>, <em class="sig-param">name='png_files'</em>, <em class="sig-param">fname=None</em>, <em class="sig-param">radio_style=False</em>, <em class="sig-param">cb_files=None</em>, <em class="sig-param">cb_names=None</em>, <em class="sig-param">cb_xfracs=None</em>, <em class="sig-param">cb_yfracs=None</em>, <em class="sig-param">verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#clawpack.geoclaw.kmltools.png2kml" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a kml file <cite>fname</cite> linking overlays for each png file in <cite>png_files</cite>.</p>
<p><cite>extent</cite> is [x1,x2,y1,y2] specifying where image should be overlaid.</p>
<p><cite>png_names</cite>, if present, will give the name for each image for the
Google Earth menu.</p>
<p>If <cite>radio_style</cite> is True, set radio buttons so only one can be shown at a
time, useful for combining plots of different quantities in same file.</p>
</dd></dl>
<dl class="function">
<dt id="clawpack.geoclaw.kmltools.poly2kml">
<code class="sig-prename descclassname">clawpack.geoclaw.kmltools.</code><code class="sig-name descname">poly2kml</code><span class="sig-paren">(</span><em class="sig-param">xy</em>, <em class="sig-param">fname=None</em>, <em class="sig-param">name='poly'</em>, <em class="sig-param">color='00FF00'</em>, <em class="sig-param">width=3</em>, <em class="sig-param">verbose=True</em>, <em class="sig-param">max_vertices_in_description=20</em><span class="sig-paren">)</span><a class="headerlink" href="#clawpack.geoclaw.kmltools.poly2kml" title="Permalink to this definition">¶</a></dt>
<dd><p>Make a KML polygon with default color blue.</p>
<dl class="field-list simple">
<dt class="field-odd">Inputs</dt>
<dd class="field-odd"><ul class="simple">
<li><p><em>xy</em> a tuple (x,y) where x and y are lists of vertices</p></li>
<li><p><em>fname</em> (str) name of resulting kml file</p></li>
<li><p><em>name</em> (str) name to appear in box on Google Earth</p></li>
<li><p><em>color</em> (str) Color in format aabbggrr</p></li>
<li><p><em>width</em> (str) line width</p></li>
<li><p><em>verbose</em> (bool) - If <em>True</em>, print out info</p></li>
<li><p><em>max_vertices_in_description</em> (int) - if more than this number
of vertices, only list number in description box, not all vertices</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="clawpack.geoclaw.kmltools.quad2kml">
<code class="sig-prename descclassname">clawpack.geoclaw.kmltools.</code><code class="sig-name descname">quad2kml</code><span class="sig-paren">(</span><em class="sig-param">xy</em>, <em class="sig-param">fname=None</em>, <em class="sig-param">name='quad'</em>, <em class="sig-param">color='FF0000'</em>, <em class="sig-param">width=3</em>, <em class="sig-param">verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#clawpack.geoclaw.kmltools.quad2kml" title="Permalink to this definition">¶</a></dt>
<dd><p>Make a KML quadrilateral with default color blue.</p>
<dl class="field-list simple">
<dt class="field-odd">Inputs</dt>
<dd class="field-odd"><ul class="simple">
<li><dl class="simple">
<dt><em>xy</em> a tuple ((x1,x2,x3,x4),(y1,y2,y3,y4)) (preferred) </dt><dd><p>or (x1,x2,y1,y2,x3,y3,x4,y4) (for backward compatibility)</p>
</dd>
</dl>
</li>
<li><p><em>fname</em> (str) name of resulting kml file</p></li>
<li><p><em>name</em> (str) name to appear in box on Google Earth</p></li>
<li><p><em>color</em> (str) Color in format aabbggrr</p></li>
<li><p><em>width</em> (str) line width</p></li>
<li><p><em>verbose</em> (bool) - If <em>True</em>, print out info</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="clawpack.geoclaw.kmltools.regions2kml">
<code class="sig-prename descclassname">clawpack.geoclaw.kmltools.</code><code class="sig-name descname">regions2kml</code><span class="sig-paren">(</span><em class="sig-param">rundata=None</em>, <em class="sig-param">fname='regions.kml'</em>, <em class="sig-param">verbose=True</em>, <em class="sig-param">combined=True</em><span class="sig-paren">)</span><a class="headerlink" href="#clawpack.geoclaw.kmltools.regions2kml" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a KML box for each AMR region specified for a GeoClaw run.</p>
<dl class="field-list">
<dt class="field-odd">Inputs</dt>
<dd class="field-odd"><ul>
<li><p><em>rundata</em> - an object of class <em>ClawRunData</em> or None</p>
<p>If <em>rundata==None</em>, try to create based on executing function <em>setrun</em>
from the <cite>setrun.py</cite> file in the current directory.</p>
</li>
<li><p><em>fname</em> (str) - resulting kml file.</p></li>
<li><p><em>verbose</em> (bool) - If <em>True</em>, print out info about each region found</p></li>
<li><p><em>combined</em> (bool) - If <em>True</em>, combine into single kml file with
name given by <em>fname</em>. This is the default.
If False, <em>fname</em> 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.</p></li>
</ul>
</dd>
</dl>
<p>First create a box for the entire domain (in red) and then a box
for each region (in white).</p>
<dl class="field-list">
<dt class="field-odd">Example</dt>
<dd class="field-odd"><div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">clawpack.geoclaw</span> <span class="kn">import</span> <span class="n">kmltools</span>
<span class="gp">>>> </span><span class="n">kmltools</span><span class="o">.</span><span class="n">regions2kml</span><span class="p">()</span>
</pre></div>
</div>
</dd>
</dl>
<p>is equivalent to:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">clawpack.geoclaw</span> <span class="kn">import</span> <span class="n">kmltools</span>
<span class="gp">>>> </span><span class="kn">from</span> <span class="nn">setrun</span> <span class="kn">import</span> <span class="n">setrun</span>
<span class="gp">>>> </span><span class="n">rundata</span> <span class="o">=</span> <span class="n">setrun</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">kmltools</span><span class="o">.</span><span class="n">regions2kml</span><span class="p">(</span><span class="n">rundata</span><span class="p">)</span>
</pre></div>
</div>
<p>By default this creates a file named <em>regions.kml</em> that can be opened in
Google Earth.</p>
</dd></dl>
<dl class="function">
<dt id="clawpack.geoclaw.kmltools.topo2kml">
<code class="sig-prename descclassname">clawpack.geoclaw.kmltools.</code><code class="sig-name descname">topo2kml</code><span class="sig-paren">(</span><em class="sig-param">topo_file_name</em>, <em class="sig-param">topo_type</em>, <em class="sig-param">color='00FF00'</em><span class="sig-paren">)</span><a class="headerlink" href="#clawpack.geoclaw.kmltools.topo2kml" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a kml file putting a box around the region covered by a topofile.
Color is green by default.</p>
</dd></dl>
<dl class="function">
<dt id="clawpack.geoclaw.kmltools.topo2kmz">
<code class="sig-prename descclassname">clawpack.geoclaw.kmltools.</code><code class="sig-name descname">topo2kmz</code><span class="sig-paren">(</span><em class="sig-param">topo</em>, <em class="sig-param">zlim=(-20</em>, <em class="sig-param">20)</em>, <em class="sig-param">mask_outside_zlim=True</em>, <em class="sig-param">sea_level=0.0</em>, <em class="sig-param">name='topo'</em>, <em class="sig-param">force_dry=None</em>, <em class="sig-param">close_figs=True</em><span class="sig-paren">)</span><a class="headerlink" href="#clawpack.geoclaw.kmltools.topo2kmz" title="Permalink to this definition">¶</a></dt>
<dd><p>Create kmz file showing onshore and offshore topography as separate layers.
Currently not very flexible but is useful in quickly creating kmz files
to open on Google Earth showing the onshore topography and offshore
bathymetry as two separate layers. Constant colors on rectangular grid
cells should be properly rendered to ease exploration of DEMs.
A colorbar png file is also created and included in the kmz file.</p>
<dl class="field-list simple">
<dt class="field-odd">Input</dt>
<dd class="field-odd"><ul class="simple">
<li><p><em>topo</em> should be a topotools.Topography object,</p></li>
<li><p><em>zlim</em> is the elevation z limits for choosing the color map</p></li>
<li><p><em>mask_outside_zlim</em> if True, suppress plotting outsize <cite>zlim</cite></p></li>
<li><p><em>sea_level</em> is the break between water and land colors</p></li>
<li><p><em>name</em> is used in the kml menu and file name</p></li>
<li><p><em>force_dry</em> is currently not used</p></li>
<li><p><em>close_figs</em> to close the pyplot figures after making png files</p></li>
</ul>
</dd>
<dt class="field-even">Future</dt>
<dd class="field-even"><p></p></dd>
</dl>
<div class="system-message">
<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/Users/rjl/Downloads/clawpack-v5.9.0/geoclaw/src/python/geoclaw/kmltools.py:docstring of clawpack.geoclaw.kmltools.topo2kmz</span>, line 18)</p>
<p>Field list ends without a blank line; unexpected unindent.</p>
</div>
<p>If <cite>force_dry</cite> is an array of the same shape as <cite>topo.Z</cite> then another png
and kml file are created for land that is below <cite>sea_level</cite> but where
<cite>force_dry = True</cite>.</p>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p><a href="http://clawpack.org/">
<img class="logo" src= "_static/clawlogo.jpg" alt="Logo"/>
</a>
<h2>Version 5.2.1</h2>
</p>
<h3><a href="contents.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">kmltools module of utility functions</a><ul>
<li><a class="reference internal" href="#module-clawpack.geoclaw.kmltools">Documentation auto-generated from the module docstrings</a></li>
</ul>
</li>
</ul>
<h3>Related Topics</h3>
<ul>
<li><a href="contents.html">Documentation overview</a><ul>
</ul></li>
</ul>
<div class="widget navlinks">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/kmltools_module.rst.txt"
rel="nofollow"
target="_blank">Source .rst</a></li>
<li><a href="https://github.com/clawpack/doc/blob/dev/doc/kmltools_module.rst"
rel="nofollow"
target="_blank">Source on GitHub</a></li>
<li><a href="https://github.com/clawpack/doc/commits/dev/doc/kmltools_module.rst"
rel="nofollow"
target="_blank">History</a></li>
<li><a href="https://github.com/clawpack/doc/edit/dev/doc/kmltools_module.rst"
rel="nofollow"
target="_blank">Suggest Edits</a></li>
<li><a href="https://github.com/clawpack/doc/issues/new/choose"
rel="nofollow"
target="_blank">Raise an Issue</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
<h4>Latest Version</h4>
<ul>
<li><a href="../dev/kmltools_module.html">dev</a></li>
<li><a href="../v5.9.x/kmltools_module.html">v5.9.x</a></li>
</ul>
<h4>Older Versions</h4>
<ul>
<li><a href="../v5.1.x/index.html">v5.1.x</a></li>
<li><a href="kmltools_module.html">v5.2.x</a></li>
<li><a href="../v5.3.x/kmltools_module.html">v5.3.x</a></li>
<li><a href="../v5.4.x/kmltools_module.html">v5.4.x</a></li>
<li><a href="../v5.5.x/kmltools_module.html">v5.5.x</a></li>
<li><a href="../v5.6.x/kmltools_module.html">v5.6.x</a></li>
<li><a href="../v5.7.x/kmltools_module.html">v5.7.x</a></li>
<li><a href="../v5.8.x/kmltools_module.html">v5.8.x</a></li>
</ul>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
© Copyright CC-BY 2022, The Clawpack Development Team.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
</div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-44811544-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>