I am trying to run this Code
import os import numpy as np import pandas as pd import matplotlib.pyplot as plt import xarray as xr import rioxarray as rxr import as ccrs import cartopy.feature as cfeature import seaborn as sns import geopandas as gpd # Plotting options sns.set(font_scale=1.3) sns.set_style("white") data= xr.open_dataset(r'C:UserspaeliDocumentsProject CAStudionetCDFpev.nc') # View xarray object #print(data) # Select a single x,y combination from the data key=121 longitude = data["pev"]["longitude"].values[key] latitude = data["pev"]["latitude"].values[key] print("Long, Lat values:", longitude, latitude) # Slice the data spatially using a single lat/lon point one_point = data["pev"].sel(latitude=latitude, longitude=longitude) # Notice the shape of the output array one_point.shape # View the first 5 values for that single point one_point.values[:5] # Use xarray to create a quick time series plot one_point.plot.line() plt.show() # clean up plot using standard matplotlib approaches f, ax = plt.subplots(figsize=(12, 6)) one_point.plot.line(hue='lat', marker="o", ax=ax, color="grey", markerfacecolor="purple", markeredgecolor="purple") ax.set(title="Time Series For a Single Lat / Lon Location") # export the figure as a .png file # plt.savefig("single_point_timeseries.png") plt.show() # Convert to dataframe -- then this can easily be exported to a csv one_point_df = one_point.to_dataframe() # Export data to .csv file one_point_df.to_csv("one-location.csv") #for a whole region start_date = "1994-01-01" end_date = "2024-01-01" pev_central_asia = data["pev"].sel( valid_time=slice(start_date, end_date)) pev_central_asia pev_central_asia.plot() plt.show() # Quickly plot the data using xarray.plot() pev_central_asia.plot(x="longitude", y="latitude", col="valid_time", col_wrap=1) plt.suptitle("Time Steps of Monthly Average Temp", y=1.03) plt.show()cartopy.crs
But at the last step it says Image is to big.
ValueError: Image size of 400x108300 pixels is too large. It must be less than 2^16 in each direction.
How does one rescale the image?
I tried adding this without success:
figure(figsize=(8, 6), dpi=80)
submitted by /u/Vriherre
[link] [comments]
r/learnpython I am trying to run this Code import os import numpy as np import pandas as pd import matplotlib.pyplot as plt import xarray as xr import rioxarray as rxr import as ccrs import cartopy.feature as cfeature import seaborn as sns import geopandas as gpd # Plotting options sns.set(font_scale=1.3) sns.set_style(“white”) data= xr.open_dataset(r’C:UserspaeliDocumentsProject CAStudionetCDFpev.nc’) # View xarray object #print(data) # Select a single x,y combination from the data key=121 longitude = data[“pev”][“longitude”].values[key] latitude = data[“pev”][“latitude”].values[key] print(“Long, Lat values:”, longitude, latitude) # Slice the data spatially using a single lat/lon point one_point = data[“pev”].sel(latitude=latitude, longitude=longitude) # Notice the shape of the output array one_point.shape # View the first 5 values for that single point one_point.values[:5] # Use xarray to create a quick time series plot one_point.plot.line() plt.show() # clean up plot using standard matplotlib approaches f, ax = plt.subplots(figsize=(12, 6)) one_point.plot.line(hue=’lat’, marker=”o”, ax=ax, color=”grey”, markerfacecolor=”purple”, markeredgecolor=”purple”) ax.set(title=”Time Series For a Single Lat / Lon Location”) # export the figure as a .png file # plt.savefig(“single_point_timeseries.png”) plt.show() # Convert to dataframe — then this can easily be exported to a csv one_point_df = one_point.to_dataframe() # Export data to .csv file one_point_df.to_csv(“one-location.csv”) #for a whole region start_date = “1994-01-01” end_date = “2024-01-01” pev_central_asia = data[“pev”].sel( valid_time=slice(start_date, end_date)) pev_central_asia pev_central_asia.plot() plt.show() # Quickly plot the data using xarray.plot() pev_central_asia.plot(x=”longitude”, y=”latitude”, col=”valid_time”, col_wrap=1) plt.suptitle(“Time Steps of Monthly Average Temp”, y=1.03) plt.show()cartopy.crs But at the last step it says Image is to big. ValueError: Image size of 400×108300 pixels is too large. It must be less than 2^16 in each direction. How does one rescale the image? I tried adding this without success: figure(figsize=(8, 6), dpi=80) submitted by /u/Vriherre [link] [comments]
I am trying to run this Code
import os import numpy as np import pandas as pd import matplotlib.pyplot as plt import xarray as xr import rioxarray as rxr import as ccrs import cartopy.feature as cfeature import seaborn as sns import geopandas as gpd # Plotting options sns.set(font_scale=1.3) sns.set_style("white") data= xr.open_dataset(r'C:UserspaeliDocumentsProject CAStudionetCDFpev.nc') # View xarray object #print(data) # Select a single x,y combination from the data key=121 longitude = data["pev"]["longitude"].values[key] latitude = data["pev"]["latitude"].values[key] print("Long, Lat values:", longitude, latitude) # Slice the data spatially using a single lat/lon point one_point = data["pev"].sel(latitude=latitude, longitude=longitude) # Notice the shape of the output array one_point.shape # View the first 5 values for that single point one_point.values[:5] # Use xarray to create a quick time series plot one_point.plot.line() plt.show() # clean up plot using standard matplotlib approaches f, ax = plt.subplots(figsize=(12, 6)) one_point.plot.line(hue='lat', marker="o", ax=ax, color="grey", markerfacecolor="purple", markeredgecolor="purple") ax.set(title="Time Series For a Single Lat / Lon Location") # export the figure as a .png file # plt.savefig("single_point_timeseries.png") plt.show() # Convert to dataframe -- then this can easily be exported to a csv one_point_df = one_point.to_dataframe() # Export data to .csv file one_point_df.to_csv("one-location.csv") #for a whole region start_date = "1994-01-01" end_date = "2024-01-01" pev_central_asia = data["pev"].sel( valid_time=slice(start_date, end_date)) pev_central_asia pev_central_asia.plot() plt.show() # Quickly plot the data using xarray.plot() pev_central_asia.plot(x="longitude", y="latitude", col="valid_time", col_wrap=1) plt.suptitle("Time Steps of Monthly Average Temp", y=1.03) plt.show()cartopy.crs
But at the last step it says Image is to big.
ValueError: Image size of 400x108300 pixels is too large. It must be less than 2^16 in each direction.
How does one rescale the image?
I tried adding this without success:
figure(figsize=(8, 6), dpi=80)
submitted by /u/Vriherre
[link] [comments]