Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single axis tracking #138

Open
wants to merge 14 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pvdeg/data/H2Opermeation.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"source": "unpublished measurements",
"Fickian": true,
"Ead": 61.4781422330562,
"Do": 25790.6020262449,
"Do": 257.906020262449,
"Eas": 5.88752263485353,
"So": 0.00982242435416737,
"Eap": 67.3656648679097,
"Po": 5559396276.60964
"So": 0.0982242435416737,
"Eap": 66.9611315410624,
"Po": 189338932521.637
},
"W003": {
"name": "Coveme",
Expand Down
53 changes: 29 additions & 24 deletions pvdeg/geospatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def start_dask(hpc=None):

client = Client(cluster)
print("Dashboard:", client.dashboard_link)
client.wait_for_workers(n_workers=1)
# client.wait_for_workers(n_workers=1)

return client

Expand Down Expand Up @@ -927,7 +927,10 @@ def elevation_stochastic_downselect(


def interpolate_analysis(
result: xr.Dataset, data_var: str, method="nearest", resolution=100j,
result: xr.Dataset,
data_var: str,
method="nearest",
resolution=100j,
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
"""
Interpolate sparse spatial result data against DataArray coordinates.
Expand Down Expand Up @@ -965,12 +968,12 @@ def interpolate_analysis(

# api could be updated to match that of plot_USA
def plot_sparse_analysis(
result: xr.Dataset,
data_var: str,
method="nearest",
resolution:complex=100j,
figsize:tuple=(10,8),
show_plot:bool=False,
result: xr.Dataset,
data_var: str,
method="nearest",
resolution: complex = 100j,
figsize: tuple = (10, 8),
show_plot: bool = False,
) -> None:
"""
Plot the output of a sparse geospatial analysis using interpolation.
Expand All @@ -982,7 +985,7 @@ def plot_sparse_analysis(
data_var: str
name of datavariable to plot from result
method: str
interpolation method.
interpolation method.
Options: `'nearest', 'linear', 'cubic'`
See [`scipy.interpolate.griddata`](https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.griddata.html)
resolution: complex
Expand All @@ -1000,7 +1003,9 @@ def plot_sparse_analysis(
)

fig = plt.figure(figsize=figsize)
ax = fig.add_axes([0, 0, 1, 1], projection=ccrs.LambertConformal(), frameon=False) # these should be the same ccrs
ax = fig.add_axes(
[0, 0, 1, 1], projection=ccrs.LambertConformal(), frameon=False
) # these should be the same ccrs
ax.patch.set_visible(False)

extent = [lon.min(), lon.max(), lat.min(), lat.max()]
Expand All @@ -1010,7 +1015,7 @@ def plot_sparse_analysis(
extent=extent,
origin="lower",
cmap="viridis",
transform=ccrs.PlateCarree(), # why are ccrs different
transform=ccrs.PlateCarree(), # why are ccrs different
)

shapename = "admin_1_states_provinces_lakes"
Expand All @@ -1031,22 +1036,22 @@ def plot_sparse_analysis(
plt.title(f"Interpolated Sparse Analysis, {data_var}")
plt.xlabel("Longitude")
plt.ylabel("Latitude")

if show_plot:
plt.show()

return fig, ax


def plot_sparse_analysis_land(
result: xr.Dataset,
data_var: str,
method="nearest",
resolution:complex=100j,
figsize:tuple=(10,8),
show_plot:bool=False,
result: xr.Dataset,
data_var: str,
method="nearest",
resolution: complex = 100j,
figsize: tuple = (10, 8),
show_plot: bool = False,
proj=ccrs.PlateCarree(),
):

import matplotlib.path as mpath
from cartopy.mpl.patch import geos_to_path

Expand All @@ -1061,7 +1066,7 @@ def plot_sparse_analysis_land(
extent = [lon.min(), lon.max(), lat.min(), lat.max()]
ax.set_extent(extent, crs=proj)

mesh = ax.pcolormesh(lon, lat, grid_values, transform=proj, cmap='viridis')
mesh = ax.pcolormesh(lon, lat, grid_values, transform=proj, cmap="viridis")

land_path = geos_to_path(list(cfeature.LAND.geometries()))
land_path = mpath.Path.make_compound_path(*land_path)
Expand All @@ -1078,15 +1083,15 @@ def plot_sparse_analysis_land(
proj,
facecolor="none",
edgecolor="black",
linestyle=':'
linestyle=":",
)

cbar = plt.colorbar(mesh, ax=ax, orientation="vertical", fraction=0.02, pad=0.04)
cbar.set_label("Value")

utilities._add_cartopy_features(
ax=ax,
features = [
ax=ax,
features=[
cfeature.BORDERS,
cfeature.COASTLINE,
cfeature.LAND,
Expand All @@ -1097,4 +1102,4 @@ def plot_sparse_analysis_land(
if show_plot:
plt.show()

return fig, ax
return fig, ax
Loading
Loading