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

Improving resolution when setting extent #2979

Open
ustropics opened this issue Nov 13, 2024 · 2 comments
Open

Improving resolution when setting extent #2979

ustropics opened this issue Nov 13, 2024 · 2 comments

Comments

@ustropics
Copy link

ustropics commented Nov 13, 2024

I am having an issue on exactly what would give me 'true' resolution of a geostationary data set (GOES in particular) while allowing for conversion to cartopy. I have provided minimal code to reproduce below, but what would give me the highest resolution when setting a more 'zoomed' in extent? Is this where I need to use native resampling or are there some attributes I'm missing?

area_def = create_area_def(
    'composite_area',  # Name of the area definition
    proj_dict,
    units='degrees',
    width=5240, 
    height=5240,
    area_extent=[lon_min, lat_min, lon_max, lat_max]
)

scn.load([recipe])
new_scn = scn.resample(area_def, resampler='nearest', cache_dir='cache/')

area = new_scn[recipe].attrs['area']
        
plt_scn = scn.resample(area)

image = get_enhanced_image(plt_scn[recipe]).data
crs = plt_scn[recipe].attrs['area'].to_cartopy_crs()

fig = plt.figure(figsize=(15,15))
ax = fig.add_subplot(1, 1, 1, projection=crs)

ax.add_feature(cfeature.COASTLINE, edgecolor=data['border_color_val'], linewidth=float(data['border_width_val']))
ax.add_feature(cfeature.BORDERS, edgecolor=data['border_color_val'], linewidth=float(data['border_width_val']))
ax.add_feature(cfeature.STATES, edgecolor=data['border_color_val'], linewidth=float(data['border_width_val']))
ax.gridlines(draw_labels=True, linewidth=0.5, color='gray', alpha=0.5, linestyle='--')

if len(plt_scn[recipe].shape) > 2:
    print("ax: ", ax)
    image.plot.imshow(vmin=0, vmax=1, add_colorbar=False, rgb='bands', ax=ax)
else:  # Single-band grayscale case
    image = np.squeeze(image)
    image.plot.imshow(vmin=0, vmax=1, add_colorbar=False, ax=ax)

plt.savefig(filename, dpi=300, bbox_inches='tight')
plt.close()

In this particular image below, I've set the extent for Florida (info below) and the recipe/composite to cimss_true_color_sunz_rayleigh:

  {
    "location": "Florida",
    "extent": [-87.634, -80.031, 24.396, 31.0],
    "satellite": "GOES-EAST (16)",
    "domain": "C",
    "projection": "Transverse Mercator",
    "central_longitude": -83.83250000000001,
    "central_latitude": 27.698,
    "standard_parallel": [24.396, 31.0]
  }

When cross-comparing this to products I've created in goes2go and to NESDIS satellite output, this appears to not match the resolution for the green/blue abi-bands (3 and 1). I'm confident this is just a lack of my understanding on how to sample properly or missing an attribute, but where am I going wrong?

My output image:
0f87299b20238907a0a8dd86c688faa6c38763753da02a0a73222e838e9eff99-ezgif com-webp-to-jpg-converter

@djhoese
Copy link
Member

djhoese commented Nov 14, 2024

Do you have an example image from those other tools? Or can you provide more details about what's signaling a lower resolution when you look at this image? I assume the size of your area is similar to the size of the images you're comparing against?

@guidocioni
Copy link

guidocioni commented Nov 14, 2024

I'm replying because you use an approach that is quite similar to mine and I had this issue in the past.

  1. Did you try to provide interpolation=none when calling imshow?
  2. Also I think that you don't need to specify the area when resampling. You can just do
scn = satpy.Scene(**scene_inputs)
scn.load(['ash'], upper_right_corner='NE')
scn = scn.crop(ll_bbox=tuple(cust_area))
scn = scn.resample(resampler='native')

which should hopefully choose the highest possible resolution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants