How to use show_domain method in tempest

Best Python code snippet using tempest_python

show_domain_with_drainage_area.py

Source:show_domain_with_drainage_area.py Github

copy

Full Screen

...13from crcm5.mh_domains import default_domains14from crcm5.mh_domains.utils.region_and_mask import get_rectangular_region_from_mask_and_margin15from domains.grid_config import GridConfig16img_folder = "mh"17def show_domain(grid_config, halo=None, blending=None, draw_rivers=True, grdc_basins_of_interest=None,18 directions_file=None, imgfile_prefix="bc-mh", include_buffer=True, ax=None, basin_border_width=1.5,19 path_to_shape_with_focus_polygons=None, nc_varname_to_show="accumulation_area", clevels=None,20 draw_colorbar=True):21 assert isinstance(grid_config, GridConfig)22 is_subplot = ax is not None23 data_mask = None24 fig = None25 if not is_subplot:26 fig = plt.figure()27 ax = plt.gca()28 halo = 10 if halo is None else halo29 blending = 10 if blending is None else blending30 if include_buffer:31 bmp = grid_config.get_basemap(resolution="l")32 else:33 bmp = grid_config.get_basemap_for_free_zone(resolution="f")34 margin = halo + blending35 nx = grid_config.ni if include_buffer else (grid_config.ni - 2 * grid_config.halo - 2 * grid_config.blendig)36 ny = grid_config.nj if include_buffer else (grid_config.nj - 2 * grid_config.halo - 2 * grid_config.blendig)37 ncells = nx * ny38 if directions_file is not None:39 with Dataset(directions_file) as ds:40 lons2d, lats2d, data = [ds.variables[k][:] for k in ["lon", "lat", nc_varname_to_show]]41 # Focus over the selected watersheds42 mask_margin = int(5 * 0.44 / grid_config.dx) # to keep the domain sizes approximately the same for all resolutions43 mask_margin = max(mask_margin, 1)44 print(mask_margin)45 if path_to_shape_with_focus_polygons is not None:46 bmp, data_mask = grid_config.get_basemap_using_shape_with_polygons_of_interest(47 lons2d[margin:-margin, margin:-margin],48 lats2d[margin:-margin, margin:-margin],49 shp_path=path_to_shape_with_focus_polygons,50 mask_margin=mask_margin, resolution="f")51 bmp.readshapefile(path_to_shape_with_focus_polygons[:-4], "basins", linewidth=basin_border_width, color="m")52 ncells = (data_mask > 0.5).sum()53 xxx, yyy = bmp(lons2d[margin:-margin, margin:-margin], lats2d[margin:-margin, margin:-margin])54 data = data[margin:-margin, margin:-margin]55 if data_mask is not None:56 # subset the data for plotting with imshow (not required for contourf)57 imin, imax, jmin, jmax = get_rectangular_region_from_mask_and_margin(data_mask > 0.5, margin_points=mask_margin)58 data = np.ma.masked_where(data_mask < 0.5, data)59 data = data[imin:imax + 1, jmin:jmax + 1]60 print("plotting {}, range: {} ... {} ".format(nc_varname_to_show, data.min(), data.max()))61 lon_copy = lons2d.copy()[margin:-margin, margin:-margin]62 lon_copy[lon_copy > 180] -= 36063 lat_copy = lats2d.copy()[margin:-margin, margin:-margin]64 to_plot = maskoceans(lon_copy, lat_copy, data)65 if clevels is not None:66 bn = BoundaryNorm(clevels, len(clevels) - 1)67 cmap = cm.get_cmap("bone_r", bn.N)68 im = bmp.imshow(to_plot.T, cmap=cmap, interpolation="nearest", norm=bn)69 else:70 # im = bmp.contourf(xxx, yyy, data, cmap="bone_r", norm=LogNorm())71 im = bmp.imshow(to_plot.T, cmap="bone_r", interpolation="nearest", norm=LogNorm())72 if draw_colorbar:73 # bmp.colorbar(im, format=ScalarFormatter(useMathText=True, useOffset=False))74 bmp.colorbar(im)75 # bmp.readshapefile(default_domains.MH_BASINS_PATH[:-4], "basin", color="m", linewidth=basin_border_width)76 if grdc_basins_of_interest is not None:77 # Select which basins to show78 bmp.readshapefile(default_domains.GRDC_BASINS_PATH[:-4], "basin", drawbounds=False)79 patches = []80 for info, shape in zip(bmp.basin_info, bmp.basin):81 if info["BASIN_ID"] in grdc_basins_of_interest:82 patches.append(Polygon(np.array(shape), True))83 ax.add_collection(84 PatchCollection(patches, facecolor='none', edgecolor='r', linewidths=basin_border_width, zorder=2))85 lons, lats = grid_config.get_free_zone_corners(halo=halo, blending=blending)86 xx, yy = bmp(lons, lats)87 coords = [(xx[0, 0], yy[0, 0]), (xx[0, -1], yy[0, -1]), (xx[-1, -1], yy[-1, -1]), (xx[-1, 0], yy[-1, 0])]88 ax.add_patch(Polygon(coords, facecolor="none"))89 if draw_rivers:90 bmp.drawrivers()91 bmp.drawcoastlines(linewidth=0.3, ax=ax)92 bmp.drawstates(linewidth=0.3, ax=ax)93 bmp.drawcountries(linewidth=0.3, ax=ax)94 bmp.drawmapboundary(fill_color="aqua")95 p = Path(img_folder)96 if not p.exists():97 p.mkdir()98 ax.set_title(r"{} cells, $\Delta x$ = {}$^\circ$".format(ncells, grid_config.dx))99 if not is_subplot:100 img_file = p.joinpath("{}_dx{}.png".format(imgfile_prefix, grid_config.dx))101 print("Saving {}".format(img_file))102 fig.savefig(str(img_file), bbox_inches="tight",103 transparent=False, dpi=300)104 plt.close(fig)105 return im106def show_all_domains():107 transparent = True108 from util import plot_utils109 plot_utils.apply_plot_params(width_cm=17, height_cm=6.5, font_size=8)110 img_folder_path = Path(img_folder)111 fig1 = plt.figure()112 gs = GridSpec(1, 3, wspace=0.0)113 ax = fig1.add_subplot(gs[0, 0])114 show_domain(default_domains.bc_mh_011,115 grdc_basins_of_interest=default_domains.GRDC_basins_of_interest,116 draw_rivers=False,117 directions_file="/RESCUE/skynet3_rech1/huziy/directions_for_ManitobaHydro/directions_mh_0.11deg.nc",118 include_buffer=False, ax=ax)119 ax = fig1.add_subplot(gs[0, 1])120 show_domain(default_domains.bc_mh_022,121 grdc_basins_of_interest=default_domains.GRDC_basins_of_interest,122 draw_rivers=False,123 directions_file="/RESCUE/skynet3_rech1/huziy/directions_for_ManitobaHydro/directions_mh_0.22deg.nc",124 include_buffer=False, ax=ax)125 ax = fig1.add_subplot(gs[0, 2])126 show_domain(default_domains.bc_mh_044,127 grdc_basins_of_interest=default_domains.GRDC_basins_of_interest,128 draw_rivers=False,129 directions_file="/RESCUE/skynet3_rech1/huziy/directions_for_ManitobaHydro/directions_mh_0.44deg.nc",130 include_buffer=False, ax=ax)131 fig1.savefig(str(img_folder_path.joinpath("bc_mh_011_022_044.png")), bbox_inches="tight", transparent=transparent,132 dpi=600)133 plt.close(fig1)134 fig2 = plt.figure()135 gs = GridSpec(1, 2, wspace=0.05)136 ax = fig2.add_subplot(gs[0, 0])137 show_domain(default_domains.gc_panarctic_05,138 grdc_basins_of_interest=default_domains.GRDC_basins_of_interest_Panarctic,139 draw_rivers=False,140 directions_file="/RESCUE/skynet3_rech1/huziy/Netbeans Projects/Java/DDM/directions_arctic_0.5deg_Bernardo.nc",141 imgfile_prefix="PanArctic_0.5deg" + "_transparent" if transparent else "",142 include_buffer=False, ax=ax)143 ax = fig2.add_subplot(gs[0, 1])144 show_domain(default_domains.gc_cordex_na_044,145 grdc_basins_of_interest=default_domains.GRDC_basins_of_interest_NA,146 draw_rivers=False,147 directions_file="/RESCUE/skynet3_rech1/huziy/Netbeans Projects/Java/DDM/directions_na_0.44deg_CORDEX.nc",148 imgfile_prefix="CORDEX_NA_0.44deg" + "_transparent" if transparent else "",149 include_buffer=False, ax=ax)150 fig2.savefig(str(img_folder_path.joinpath("NA_and_Arctic_044.png")), bbox_inches="tight", transparent=transparent,151 dpi=600)152 plt.close(fig2)153 # Great Lakes largest domain154 plot_utils.apply_plot_params(width_cm=6.5, height_cm=6.5, font_size=6)155 show_domain(default_domains.gc_GL_and_NENA_01,156 grdc_basins_of_interest=default_domains.GRDC_basins_GL,157 draw_rivers=False,158 imgfile_prefix="GL_NENA_01",159 directions_file="/RESCUE/skynet3_rech1/huziy/Netbeans Projects/Java/DDM/directions_440x260_GL+NENA_0.1deg.nc",160 include_buffer=False)161@main_decorator162def test_lake_fraction_calculation():163 show_domain(default_domains.bc_mh_044, include_buffer=False, imgfile_prefix="mh-focus-zone-lkfr_test",164 path_to_shape_with_focus_polygons=default_domains.MH_BASINS_PATH,165 directions_file="/Users/san/Java/ddm/directions_bc-mh_0.44deg.nc", nc_varname_to_show="lake_fraction")166@main_decorator167def main():168 # default_domains.bc_mh_044.export_to_shape_ogr(shp_folder="mh/shapes/", shp_filename="dx_044deg")169 # default_domains.bc_mh_044.export_to_shape_native_grid(shp_folder="mh/shapes/", shp_filename="dx_044deg")170 #171 # default_domains.bc_mh_011.decrease_resolution_keep_free_domain_same(2).export_to_shape_ogr(shp_folder="mh/shapes/", shp_filename="dx_022deg")172 #173 # default_domains.bc_mh_011.export_to_shape_ogr(shp_folder="mh/shapes/", shp_filename="dx_011deg")174 # show_domain(default_domains.bc_mh_011.decrease_resolution_keep_free_domain_same(2),175 # grdc_basins_of_interest=default_domains.GRDC_basins_of_interest,176 # draw_rivers=False,177 # directions_file=None,178 # imgfile_prefix="bc-mh_0.22deg",179 # include_buffer=False)180 # show_all_domains()181 # show_domain(default_domains.bc_mh_044, include_buffer=False, imgfile_prefix="bc-mh",182 # directions_file="/RESCUE/skynet3_rech1/huziy/Netbeans Projects/Java/DDM/directions_bc-mh_0.44deg.nc",183 # basin_border_width=0.5, grdc_basins_of_interest=default_domains.GRDC_basins_of_interest_NA)184 show_domain(default_domains.gc_GL_and_NENA_01_fft, include_buffer=False, imgfile_prefix="gl_nena_0.1",185 directions_file="/RESCUE/skynet3_rech1/huziy/Netbeans Projects/Java/DDM/directions_452x260_GL+NENA_0.1deg.nc",186 basin_border_width=0.5, grdc_basins_of_interest=default_domains.GRDC_basins_of_interest_NA,187 draw_rivers=True)188 # show_domain(default_domains.bc_mh_044, include_buffer=False, imgfile_prefix="mh-focus-zone-lkfr",189 # path_to_shape_with_focus_polygons=default_domains.MH_BASINS_PATH,190 # directions_file="/RESCUE/skynet3_rech1/huziy/Netbeans Projects/Java/DDM/directions_bc-mh_0.44deg.nc",191 # basin_border_width=0.5)192 # show_domain(default_domains.bc_mh_022, include_buffer=False, imgfile_prefix="mh-focus-zone-lkfr",193 # path_to_shape_with_focus_polygons=default_domains.MH_BASINS_PATH,194 # directions_file="/RESCUE/skynet3_rech1/huziy/Netbeans Projects/Java/DDM/directions_bc-mh_0.22deg.nc")195 #196 # show_domain(default_domains.bc_mh_011, include_buffer=False, imgfile_prefix="mh-focus-zone-lkfr",197 # path_to_shape_with_focus_polygons=default_domains.MH_BASINS_PATH,198 # directions_file="/RESCUE/skynet3_rech1/huziy/Netbeans Projects/Java/DDM/directions_bc-mh_0.11deg.nc")199if __name__ == '__main__':200 main()...

Full Screen

Full Screen

dl_render.py

Source:dl_render.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2import types3from typing import Union, Optional4from owlready2 .disjoint import AllDisjoint5from owlready2.class_construct import LogicalClassConstruct, Or, And, Not, Inverse, \6 Construct, Restriction, OneOf, ConstrainedDatatype, PropertyChain7from owlready2.entity import EntityClass, ThingClass8from owlready2.annotation import AnnotationPropertyClass9from owlready2.prop import PropertyClass, ObjectPropertyClass, DataPropertyClass, ReasoningPropertyClass, \10 SymmetricProperty, AsymmetricProperty, TransitiveProperty, FunctionalProperty, ReflexiveProperty, \11 IrreflexiveProperty12from owlready2.namespace import owl, Ontology13import owlready2.base14_DL_SYNTAX = types.SimpleNamespace(15 SUBCLASS="⊑",16 EQUIVALENT_TO="≡",17 NOT="¬",18 DISJOINT_WITH="⊑" + " " + "¬",19 EXISTS="∃",20 FORALL="∀",21 IN="∈",22 MIN="≥",23 EQUAL="=",24 NOT_EQUAL="≠",25 MAX="≤",26 INVERSE="⁻",27 AND="⊓",28 TOP="⊤",29 BOTTOM="⊥",30 OR="⊔",31 COMP="∘",32 WEDGE="⋀",33 IMPLIES="←",34 COMMA=",",35 SELF="self",36)37_FACETS = {38 "length": "length",39 "min_length": "minLength",40 "max_length": "maxLength",41 "pattern": "pattern",42 "max_inclusive": "\u2264",43 "max_exclusive": "\u003c",44 "min_inclusive": "\u2265",45 "min_exclusive": "\u003e",46 "total_digits": "totalDigits",47 "fraction_digits": "fractionDigits",48}49def dl_render_terminology_str(onto: Ontology, show_disjoint: bool = True, show_domain: bool = True, show_range: bool = True, show_inverse: bool = True, show_characteristics: bool = False) -> str:50 s = []51 if onto.annotation_properties():52 s.extend(['',53 "##################################",54 "# Annotation properties #",55 "##################################", ''])56 for prop in onto.annotation_properties():57 s.extend(["######### %s #########" % dl_render_concept_str(prop).center(14),58 dl_render_prop_str(prop), ''])59 if onto.data_properties():60 s.extend(['',61 "##################################",62 "# Data properties #",63 "##################################", ''])64 for prop in onto.data_properties():65 s.extend(["######### %s #########" % dl_render_concept_str(prop).center(14),66 dl_render_prop_str(prop, show_domain=show_domain, show_range=show_range, show_inverse=show_inverse, show_characteristics=show_characteristics), ''])67 if onto.object_properties():68 s.extend(['',69 "##################################",70 "# Object properties #",71 "##################################", ''])72 for prop in onto.object_properties():73 s.extend(["######### %s #########" % dl_render_concept_str(prop).center(14),74 dl_render_prop_str(prop, show_domain=show_domain, show_range=show_range, show_inverse=show_inverse, show_characteristics=show_characteristics), ''])75 if onto.classes():76 s.extend(['',77 "##################################",78 "# Classes #",79 "##################################", ''])80 for klass in onto.classes():81 s.extend(["######### %s #########" % dl_render_concept_str(klass).center(14),82 dl_render_class_str(klass, show_disjoint=show_disjoint), ''])83 return "\n".join(s)84def dl_render_class_str(klass: ThingClass, show_disjoint: bool = True) -> str:85 s = []86 if klass.equivalent_to:87 s.extend(88 [("%s %s %s" % (dl_render_concept_str(klass), _DL_SYNTAX.EQUIVALENT_TO, dl_render_concept_str(_))) for _ in89 klass.equivalent_to])90 if klass.is_a:91 s.extend([("%s %s %s" % (dl_render_concept_str(klass), _DL_SYNTAX.SUBCLASS, dl_render_concept_str(_))) for _ in92 klass.is_a])93 if not s:94 s.append("%s %s %s" % (dl_render_concept_str(klass), _DL_SYNTAX.SUBCLASS, _DL_SYNTAX.TOP))95 if show_disjoint:96 for disjoint in klass.disjoints():97 s.append(dl_render_disjoint_str(disjoint, klass))98 return "\n".join(s)99def dl_render_prop_str(prop: PropertyClass, show_domain: bool = True, show_range: bool = True, show_inverse: bool = True, show_characteristics: bool = False) -> str:100 s = []101 if prop.is_a:102 s.extend([("%s %s %s" % (dl_render_concept_str(prop), _DL_SYNTAX.SUBCLASS, dl_render_concept_str(_))) for _ in103 prop.is_a if _.namespace is not owl])104 if prop.domain and show_domain:105 s.extend([("%s %s .%s %s %s" % (_DL_SYNTAX.EXISTS, prop.name, _DL_SYNTAX.TOP, _DL_SYNTAX.SUBCLASS, dl_render_concept_str(_))) for _ in prop.domain])106 if prop.range and show_range:107 s.extend([("%s %s %s %s .%s" % (_DL_SYNTAX.TOP, _DL_SYNTAX.SUBCLASS, _DL_SYNTAX.FORALL, prop.name, dl_render_concept_str(_))) for _ in prop.range])108 if prop.inverse_property and show_inverse:109 s.append("%s %s %s%s" % (prop.name, _DL_SYNTAX.EQUIVALENT_TO, dl_render_concept_str(prop.inverse_property), _DL_SYNTAX.INVERSE))110 if show_characteristics:111 if SymmetricProperty in prop.is_a:112 s.append("%s %s %s%s" % (113 prop.name, _DL_SYNTAX.SUBCLASS, prop.name, _DL_SYNTAX.INVERSE))114 if AsymmetricProperty in prop.is_a:115 s.append("%s %s %s%s%s" % (116 prop.name, _DL_SYNTAX.SUBCLASS, _DL_SYNTAX.NOT, prop.name, _DL_SYNTAX.INVERSE))117 if TransitiveProperty in prop.is_a:118 s.append("%s %s %s" % (dl_render_concept_str(PropertyChain([prop, prop])), _DL_SYNTAX.SUBCLASS, prop.name))119 if FunctionalProperty in prop.is_a:120 s.append("%s %s %s" % (_DL_SYNTAX.TOP, _DL_SYNTAX.SUBCLASS, dl_render_concept_str(prop.max(1))))121 if ReflexiveProperty in prop.is_a:122 s.append("%s %s %s" % (_DL_SYNTAX.TOP, _DL_SYNTAX.SUBCLASS, dl_render_concept_str(prop.has_self())))123 if IrreflexiveProperty in prop.is_a:124 s.append("%s %s %s" % (dl_render_concept_str(prop.has_self()), _DL_SYNTAX.SUBCLASS, _DL_SYNTAX.BOTTOM))125 return "\n".join(s)126def dl_render_disjoint_str(disjoint: AllDisjoint, klass: Optional[ThingClass] = None) -> str:127 if klass is None:128 return "\n".join(dl_render_disjoint_str(disjoint, _) for _ in disjoint.entities)129 if klass in disjoint.entities:130 return "\n".join("%s %s %s" % (dl_render_concept_str(And([klass, _])), _DL_SYNTAX.SUBCLASS, _DL_SYNTAX.BOTTOM)131 for _ in disjoint.entities if _ is not klass)132def dl_render_concept_str(concept: Union[Construct, EntityClass]) -> str:133 this = dl_render_concept_str134 if concept is None:135 return _DL_SYNTAX.BOTTOM136 if isinstance(concept, ThingClass):137 if concept is owl.Thing:138 return _DL_SYNTAX.TOP139 if concept is owl.Nothing:140 return _DL_SYNTAX.BOTTOM141 return concept.name142 if isinstance(concept, PropertyClass):143 return concept.name144 if isinstance(concept, LogicalClassConstruct):145 s = []146 for x in concept.Classes:147 if isinstance(x, LogicalClassConstruct):148 s.append("(" + this(x) + ")")149 else:150 s.append(this(x))151 if isinstance(concept, Or):152 return (" %s " % _DL_SYNTAX.OR).join(s)153 if isinstance(concept, And):154 return (" %s " % _DL_SYNTAX.AND).join(s)155 if isinstance(concept, Not):156 return "%s %s" % (_DL_SYNTAX.NOT, this(concept.Class))157 if isinstance(concept, Inverse):158 return "%s%s" % (this(concept.property), _DL_SYNTAX.INVERSE)159 if isinstance(concept, Restriction):160 # type map161 # SOME:162 # ONLY:163 # VALUE:164 # HAS_SELF:165 # EXACTLY:166 # MIN:167 # MAX:168 if concept.type == owlready2.base.SOME:169 return "%s %s .%s" % (_DL_SYNTAX.EXISTS, this(concept.property), this(concept.value))170 if concept.type == owlready2.base.ONLY:171 return "%s %s .%s" % (_DL_SYNTAX.FORALL, this(concept.property), this(concept.value))172 if concept.type == owlready2.base.VALUE:173 return "%s %s .{%s}" % (_DL_SYNTAX.EXISTS, this(concept.property), concept.value.name if isinstance(concept.value, owl.Thing) else concept.value)174 if concept.type == owlready2.base.HAS_SELF:175 return "%s %s .%s" % (_DL_SYNTAX.EXISTS, this(concept.property), _DL_SYNTAX.SELF)176 if concept.type == owlready2.base.EXACTLY:177 return "%s %s %s .%s" % (_DL_SYNTAX.EQUAL, concept.cardinality, this(concept.property), this(concept.value))178 if concept.type == owlready2.base.MIN:179 return "%s %s %s .%s" % (_DL_SYNTAX.MIN, concept.cardinality, this(concept.property), this(concept.value))180 if concept.type == owlready2.base.MAX:181 return "%s %s %s .%s" % (_DL_SYNTAX.MAX, concept.cardinality, this(concept.property), this(concept.value))182 if isinstance(concept, OneOf):183 return "{%s}" % (" %s " % _DL_SYNTAX.OR).join("%s" % (_.name if isinstance(_, owl.Thing) else _) for _ in concept.instances)184 if isinstance(concept, ConstrainedDatatype):185 s = []186 for k in _FACETS:187 v = getattr(concept, k, None)188 if not v is None:189 s.append("%s %s" % (_FACETS[k], v))190 return "%s[%s]" % (concept.base_datatype.__name__, (" %s " % _DL_SYNTAX.COMMA).join(s))191 if isinstance(concept, PropertyChain):192 return (" %s " % _DL_SYNTAX.COMP).join(this(_) for _ in concept.properties)193 if concept in owlready2.base._universal_datatype_2_abbrev:194 iri = owlready2.base._universal_abbrev_2_iri.get(owlready2.base._universal_datatype_2_abbrev.get(concept))195 if iri.startswith("http://www.w3.org/2001/XMLSchema#"):196 return "xsd:" + iri[33:]197 hash, slash = iri.rindex('#'), iri.rindex('/')198 return iri[max(hash, slash)+1:]199 if owlready2.rdfs_datatype in [_.storid for _ in concept.is_a]: # rdfs:Datatype200 return concept.name...

Full Screen

Full Screen

show_domains.py

Source:show_domains.py Github

copy

Full Screen

...11default_img_folder = "mh"12def show_multiple_domains(label_to_config):13 # TODO: implement14 pass15def show_domain(grid_config, halo=None, blending=None, draw_rivers=True, show_GRDC_basins=False,16 show_Churchil_Nelson_basins=True, img_folder=None,17 domain_label="mh", ax=None):18 assert isinstance(grid_config, GridConfig)19 fig = None20 if ax is None:21 fig = plt.figure()22 ax = plt.gca()23 halo = 10 if halo is None else halo24 blending = 10 if blending is None else blending25 bmp = grid_config.get_basemap(resolution="i")26 if show_Churchil_Nelson_basins:27 bmp.readshapefile(default_domains.MH_BASINS_PATH[:-4], "basin", color="m", linewidth=2)28 if show_GRDC_basins:29 # Select which basins to show30 bmp.readshapefile(default_domains.GRDC_BASINS_PATH[:-4], "basin", drawbounds=False, linewidth=0.5)31 patches = []32 for info, shape in zip(bmp.basin_info, bmp.basin):33 if info["BASIN_ID"] in default_domains.GRDC_basins_of_interest:34 patches.append(Polygon(np.array(shape), True))35 ax.add_collection(PatchCollection(patches, facecolor='none', edgecolor='b', linewidths=2., zorder=2))36 lons, lats = grid_config.get_free_zone_corners(halo=halo, blending=blending)37 xx, yy = bmp(lons, lats)38 coords = [(xx[0, 0], yy[0, 0]), (xx[0, -1], yy[0, -1]), (xx[-1, -1], yy[-1, -1]), (xx[-1, 0], yy[-1, 0])]39 ax.add_patch(Polygon(coords, facecolor="none"))40 if draw_rivers:41 bmp.drawrivers()42 bmp.drawcoastlines(linewidth=0.3, ax=ax)43 bmp.drawstates(linewidth=0.3, ax=ax)44 bmp.drawcountries(linewidth=0.3, ax=ax)45 ax.set_title(46 r"${}".format(grid_config.ni) + r"\times" + "{}$ grid cells, resolution {} $^\circ$".format(grid_config.nj,47 grid_config.dx))48 if ax is None:49 if img_folder is None:50 img_folder = default_img_folder51 p = Path(img_folder)52 if not p.exists():53 p.mkdir()54 img_file = p.joinpath("{}_dx{}.png".format(domain_label, grid_config.dx))55 print("Saving image ... {}".format(img_file))56 fig.savefig(str(img_file), bbox_inches="tight", transparent=True)57def show_bc_mh_domains():58 pass59@main_decorator60def main():61 # Show selected domains, basins, and/or flow directions or flow accumulations62 mh_gc044 = default_domains.gc_cordex_na_044.subgrid(20, 60, di=130, dj=110)63 mh_gc022 = mh_gc044.double_resolution_keep_free_domain_same()64 test_bc_011 = default_domains.gc_cordex_na_011.subgrid(12, 244, di=404, dj=380)65 test_bc_044 = test_bc_011.decrease_resolution_keep_free_domain_same(4)66 print(test_bc_044)67 plot_utils.apply_plot_params()68 # show_domain(mh_gc044)69 # show_domain(mh_gc022)70 # show_domain(mh_gc011)71 print(test_bc_011)72 # fig, ax, bmp = show_domain(default_domains.gc_cordex_011, draw_rivers=False)73 # show_domain(test_bc_011, draw_rivers=False, show_GRDC_basins=True)74 # show_domain(test_bc_044, draw_rivers=False, show_GRDC_basins=True)75 show_domain(default_domains.bc_mh_044, show_GRDC_basins=True, show_Churchil_Nelson_basins=False)76 # show_domain(default_domains.bc_mh_011)77 plt.show()78if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful