Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

NOAA20 Sea Surface Temperature

86 views
Skip to first unread message

woo...@gmail.com

unread,
Jul 24, 2024, 12:12:59 PM7/24/24
to pytroll
Hi
 
I wonder if someone with more extensive python programming knowledge can help me
 
I am trying to process the NOAA20 sea surface temperature from this file distributed
over Eumetcast in SAF-1 on the Basic service

S-OSI_-FRA_-NOAA20_-NARSST_FIELD-202407231200Z.nc
 
I run  python .\process-NorthAtlanticSST.py NA20202407231200
 
I have two problems
 
Firstly I cant seem to get a polar stereographic projection to work properly

Secondly the sea surface temperature wont plot because the  variable is empty and I dont know why - I think it may be something to do with the lat/long
 
Any help would be much appreciated
 
Thanks
 
Graham
process-NorthAtlanticSST.py

David Hoese

unread,
Jul 24, 2024, 2:16:59 PM7/24/24
to pyt...@googlegroups.com
Hi Graham,

Please provide any error messages and their complete tracebacks (if available) for the two issues you identified. Thanks.

Dave

--
You received this message because you are subscribed to the Google Groups "pytroll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pytroll+u...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/pytroll/10911491-a6cd-4b16-a8fb-4d933fe6d88an%40googlegroups.com.
Message has been deleted

woo...@gmail.com

unread,
Jul 24, 2024, 4:26:12 PM7/24/24
to pytroll
Hi Dave

These are the errors I get with the attached script

(pytroll) PS I:\SPStools\GEOscripts> python .\process-NorthAtlanticSST.py NA20202407231000
[[13.592773  13.598633  13.606445  ... 16.370117  16.364258  16.357422 ]
 [13.603516  13.611328  13.6171875 ... 16.381836  16.375977  16.370117 ]
 [13.615234  13.62207   13.628906  ... 16.393555  16.387695  16.381836 ]
 ...
 [43.756836  43.774414  43.791016  ... 51.24121   51.222656  51.20508  ]
 [43.760742  43.77832   43.79492   ... 51.24707   51.228516  51.210938 ]
 [43.76465   43.782227  43.799805  ... 51.251953  51.234375  51.21582  ]]
[[-31.868164 -31.856445 -31.844727 ...  26.786133  26.798828  26.810547]
 [-31.875    -31.863281 -31.851562 ...  26.791992  26.804688  26.817383]
 [-31.881836 -31.870117 -31.859375 ...  26.798828  26.810547  26.824219]
 ...
 [-75.96973  -75.96484  -75.958984 ...  72.89746   72.90527   72.91406 ]
 [-75.99414  -75.98828  -75.98242  ...  72.924805  72.93359   72.94336 ]
 [-76.01758  -76.01172  -76.00586  ...  72.9541    72.96289   72.9707  ]]
0
11942065
9576463
12460018
[]
Traceback (most recent call last):
  File "I:\SPStools\GEOscripts\process-NorthAtlanticSST.py", line 124, in <module>
    img = ax.imshow(data, vmin=vmin, vmax=vmax, origin='upper', extent=img_extent, cmap=cmap)
  File "C:\Users\graha\miniconda3\envs\pytroll\lib\site-packages\cartopy\mpl\geoaxes.py", line 307, in wrapper
    return func(self, *args, **kwargs)
  File "C:\Users\graha\miniconda3\envs\pytroll\lib\site-packages\cartopy\mpl\geoaxes.py", line 1314, in imshow
    img, extent = warp_array(img,
  File "C:\Users\graha\miniconda3\envs\pytroll\lib\site-packages\cartopy\img_transform.py", line 192, in warp_array
    array = regrid(array, source_native_xy[0], source_native_xy[1],
  File "C:\Users\graha\miniconda3\envs\pytroll\lib\site-packages\cartopy\img_transform.py", line 293, in regrid
    temp_array = array.reshape((-1,) + array.shape[2:])
  File "C:\Users\graha\miniconda3\envs\pytroll\lib\site-packages\numpy\ma\core.py", line 4745, in reshape
    result = self._data.reshape(*s, **kwargs).view(type(self))
ValueError: cannot reshape array of size 0 into shape (0)
process-NorthAtlanticSST.py

woo...@gmail.com

unread,
Jul 24, 2024, 4:38:09 PM7/24/24
to pytroll
Hi Dave

I should add that I am not very erprienced with python

This is a scrpit I have copied from the internet and adapted

It works with MSG and Metop data but not with NOAA20 - I get a blank map in the wrong projection with no data

Regards

Graham

Adam Dybbroe

unread,
Jul 24, 2024, 5:02:54 PM7/24/24
to pyt...@googlegroups.com, adam.d...@smhi.se

Graham,

Satpy can read these files! So, since you are here, why not use Pytroll libraries?


from satpy import Scene
from satpy.utils import debug_on
debug_on()
    

SST_FILES = ["/path/to/your/SST/file/S-OSI_-FRA_-MTOP-NARSST_FIELD-202204061000Z.nc"]

scn = Scene(filenames=SST_FILES, reader='ghrsst_l2')
scn.load(['sea_surface_temperature'])

# Here we resample to the area "euron1", but you can take any area already defined in the "areas.yaml" file

local_scn = scn.resample('euron1')

local_scn.show('sea_surface_temperature')

-Adam

To view this discussion on the web, visit https://groups.google.com/d/msgid/pytroll/18047abc-3ebc-43c8-b4f0-61ef53c92650n%40googlegroups.com.
-- 
Adam Dybbroe,
Satellite Remote Sensing Scientist
Research lead - Nowcasting and Remote Sensing
Meteorological Research unit, Research and Development
Swedish Meteorological and Hydrological Institute (SMHI)
www.pytroll.org
nwcsaf.smhi.se
www.smhi.se

woo...@gmail.com

unread,
Jul 24, 2024, 5:09:09 PM7/24/24
to pytroll
Hi Adam

Thanks for the reply

I wasnt aware that you could do that with netcdf files - I will try it tomorrow

Can you do this with all SST netcdf  files from the various satellites and will it work for sea ice data too

Many thanks

Graham

Adam Dybbroe

unread,
Jul 24, 2024, 5:26:01 PM7/24/24
to pyt...@googlegroups.com, adam.d...@smhi.se

The reader is supposed to handle the GHRSST netCDF format, and I know it reads the OSISAF NAR SSTs (Metop and JPSS) and also the SLSTR SSTs.

I haven't tried it myself on the Sea Ice parameters. But as you can see it at least reads the Sea Ice fraction which is part of the SST files:

In [3]: scn.available_dataset_names()
Out[3]:
['latitude_osisaf',
 'longitude_osisaf',
 'sea_ice_fraction',
 'sea_surface_temperature']


Good luck!

-Adam

woo...@gmail.com

unread,
Jul 25, 2024, 9:28:37 AM7/25/24
to pytroll
Hi Adam

I now have an image which I have attached

I dont know how to add colour,coastlines and the colour scale bar to my image - its all black and grey

 My python skills arent quite there yet

Warm Wishes

Graham
tmpj5t8fm3d.PNG
process-NorthAtlanticSST.py

woo...@gmail.com

unread,
Jul 30, 2024, 7:53:43 AM7/30/24
to pytroll
Hi

I am assuming that I need to add a composite in order to see a colour image but Im not sure which composite to use

Any help would be much appreciated

Thanks

Graham

Adam Dybbroe

unread,
Jul 30, 2024, 10:33:47 AM7/30/24
to pyt...@googlegroups.com, adam.d...@smhi.se

Hi Graham,

You can add a custom composite as you wish. I have this one (in my case a local "visir.yaml" file in a directory called "composites" under the path pointed to by SATPY_CONFIG_PATH):


composites:

  sea_surface_temperature_bw:
    compositor: !!python/name:satpy.composites.SingleBandCompositor
    standard_name: sea_surface_temperature_bw
    prerequisites:
      - name: sea_surface_temperature

  sea_surface_temperature_smhi:
    compositor: !!python/name:satpy.composites.SingleBandCompositor
    standard_name: sea_surface_subskin_temperature_smhi
    prerequisites:
      - name: sea_surface_temperature


And then I have a custom enhancement like this one (in a file "generic.yaml" under a sub-directory called "enhancements" under the path pointed to by SATPY_CONFIG_PATH):


enhancements:
  default:
    operations:
    - name: stretch
      method: &stretchfun !!python/name:satpy.enhancements.stretch
      kwargs: {stretch: linear}

  osisaf_sst_smhi_colormap:
    standard_name: sea_surface_subskin_temperature
    operations:
    - name: osisaf_sst
      method: !!python/name:satpy.enhancements.colorize
      kwargs:
          palettes:
            - colors: [
              [255, 0, 255],
              [195, 0, 129],
              [129, 0, 47],
              [195, 0, 0],
              [255, 0, 0],
              [236, 43, 0],
              [217, 86, 0],
              [200, 128, 0],
              [211, 154, 13],
              [222, 180, 26],
              [233, 206, 39],
              [244, 232, 52],
              [255.99609375, 255.99609375, 63.22265625],
              [203.125, 255.99609375, 52.734375],
              [136.71875, 255.99609375, 27.34375],
              [0, 255.99609375, 0],
              [0, 207.47265625, 0],
              [0, 158.94921875, 0],
              [0, 110.42578125, 0],
              [0, 82.8203125, 63.99609375],
              [0, 55.21484375, 127.9921875],
              [0, 27.609375, 191.98828125],
              [0, 0, 255.99609375],
              [100.390625, 100.390625, 255.99609375],
              [150.5859375, 150.5859375, 255.99609375]]
              min_value: 296.55
              max_value: 273.55


This code should produce a colored SST with black coastlines:


    scn = Scene(filenames=SST_FILES, reader='ghrsst_l2')

    scn.load(['sea_surface_temperature_smhi', 'sea_surface_temperature'])


    local_scn = scn.resample('euron1')

    timestr = local_scn.start_time.strftime('%Y%m%d_%H%M')
    coast = {'outline': (0, 0, 0), 'width': 1.0, 'level': 1, 'resolution': 'i'}
    local_scn.save_dataset('sea_surface_temperature_smhi',
                           filename='./sst_smhi_palette_{time}.png'.format(time=timestr),
                           overlay={'coast_dir': '/home/a000680/data/shapes/',
                                    'overlays': {'coasts': coast}})


I am on holiday a couple of weeks more, so please excuse me if not responding until later in August. I suggest you continue in the channel "composites" or "satpy" on Pytroll Slack. You may be able to get faster help there.

-Adam

woo...@gmail.com

unread,
Jul 30, 2024, 3:53:24 PM7/30/24
to pytroll
Hi Adam

Its all working brilliantly now thanks very much

Enjoy your holiday

Warm Wishes

Graham

woo...@gmail.com

unread,
Jul 31, 2024, 7:39:51 AM7/31/24
to pytroll

Hi Adam

Just one more little thig and there is no rush whatsoever

I would like to add the temperature scale and legend to the image just for completeness

I have tried plt.colourbar but it doesnt work

If you could give me an example that would be great

Many thanks

Graham

Adam Dybbroe

unread,
Aug 14, 2024, 10:23:07 AM8/14/24
to pyt...@googlegroups.com, adam.d...@smhi.se

Hi Graham,

Great that you managed to get it to work as you wished!

I am catching up slowly after the holiday.

I am really not the best person for this, I haven't done much myself with pytroll except adding logos and coastlines, but the module to use here is pydecorate. https://pydecorate.readthedocs.io/en/latest/

And Satpy does implicitly support at least some features (if not all?) from pydecorate.

My suggestion to you if you want more help here would be to go to the pytroll slack channel #pycoast-pydecorate !

-Adam

woo...@gmail.com

unread,
Aug 14, 2024, 11:24:14 AM8/14/24
to pytroll
Hi Adam

I hope you had a great holiday

Many thanks for that Im sure I can do something with that

If I wanted to change your code that I have working to use a different mapping of colour to temperature how would I do that ?

I seems from the images I am producing at the moment are very deeply red/purple particularyly on the Med (see attached)

I know that Satpy has some colour tables that may give a better indication of temperature

Thanks again for your help

Warm Wishes
NA20-SST-202408131200-eurol.jpg
Reply all
Reply to author
Forward
0 new messages