Example to fetch SAR Sentinel-1 WV roughness figures from X-waves application¶
[1]:
import apixwaves
define space and time query¶
[2]:
from apixwaves import timeSpaceFileListQuery
bbox = "30,-30,-30,10"
satellite = 'S1A'
#latmin,lonmin,latmax,lonmax = 30,-30,-30,10
date_interval = "20140101010101,20170106112608"
dictQuery = timeSpaceFileListQuery.rawQuery(bbox=bbox,satellite=satellite,date_interval=date_interval)
print(len(dictQuery))
print(dictQuery[0])
500
['20170106111659', '20170106111659', [], 'S1A', 'POLYGON ((-88.41223 -29.374926, -88.61793 -29.326313, -88.5657 -29.153814, -88.36036 -29.202335, -88.41223 -29.374926))', -29.2642307281, -88.4898529053, 'wv2', '0', '1.97', ' ', 'S1A_WV_OCN__2SSV_20170106T111151_20170106T112914_014710_017F06_7DC6.SAFE/s1a-wv2-ocn-vv-20170106t111659-20170106t111701-014710-017f06-022.nc', [['0', '0', '0'], ['-1.0', '-1.0', '-1.0']], 1483701365900]
display a single spectra¶
[3]:
url_image = 'https://xwaves-services.ifremer.fr/datavore/exp/datavore/public/S1B/S1B_WV_SLC__1SSV_20211221T165539_20211221T172051_030126_0398ED_658A.SAFE/s1b-wv1-slc-vv-20211221t170920-20211221t170923-030126-0398ed-057.tiff/S1B_WV_OCN__2SSV_20211221T165539_20211221T172051_030126_0398ED_D0BA.SAFE/s1b-wv1-ocn-vv-20211221t170920-20211221t170923-030126-0398ed-057.nc/realPart/20211221170920/imageSentinel/'
from matplotlib import pyplot as plt
#import fsspec
from PIL import Image
import requests
from io import BytesIO
response = requests.get(url_image)
img = Image.open(BytesIO(response.content))
img
[3]:
reconstruct path for images¶
[4]:
pattern_url_image = 'https://xwaves-services.ifremer.fr/datavore/exp/datavore/public/%s/%s/%s/%s/%s/imageSentinel/'
import os
import numpy as np
empty_field = np.ones((142),dtype=str)
empty_field[:] = ' '
empty_field = ''.join(empty_field)
imagetype = 'realPart' # or realPart or ..
imagetype = 'roughness'
cpt_ok = 0
for acq in dictQuery:
#print(acq)
sat = acq[3]
tiffid = acq[10]
if not np.array_equal(tiffid,empty_field):
ocnuid = acq[11]
startdate = acq[0]
real_pat = os.path.join(pattern_url_image%(sat,tiffid,ocnuid,imagetype,startdate))
print(real_pat)
cpt_ok += 1
response = requests.get(real_pat)
img = Image.open(BytesIO(response.content))
plt.figure()
plt.imshow(img)
if cpt_ok>3:
break
https://xwaves-services.ifremer.fr/datavore/exp/datavore/public/S1B/S1B_WV_SLC__1SSV_20170106T105022_20170106T110548_003726_006671_84D5.SAFE/s1b-wv2-slc-vv-20170106t110545-20170106t110548-003726-006671-064.tiff/S1B_WV_OCN__2SSV_20170106T105022_20170106T110548_003726_006671_55C0.SAFE/s1b-wv2-ocn-vv-20170106t110545-20170106t110548-003726-006671-064.nc/roughness/20170106110545/imageSentinel/
https://xwaves-services.ifremer.fr/datavore/exp/datavore/public/S1B/S1B_WV_SLC__1SSV_20170106T105022_20170106T110548_003726_006671_84D5.SAFE/s1b-wv1-slc-vv-20170106t110530-20170106t110533-003726-006671-063.tiff/S1B_WV_OCN__2SSV_20170106T105022_20170106T110548_003726_006671_55C0.SAFE/s1b-wv1-ocn-vv-20170106t110530-20170106t110533-003726-006671-063.nc/roughness/20170106110530/imageSentinel/
https://xwaves-services.ifremer.fr/datavore/exp/datavore/public/S1B/S1B_WV_SLC__1SSV_20170106T105022_20170106T110548_003726_006671_84D5.SAFE/s1b-wv2-slc-vv-20170106t110516-20170106t110519-003726-006671-062.tiff/S1B_WV_OCN__2SSV_20170106T105022_20170106T110548_003726_006671_55C0.SAFE/s1b-wv2-ocn-vv-20170106t110516-20170106t110519-003726-006671-062.nc/roughness/20170106110516/imageSentinel/
https://xwaves-services.ifremer.fr/datavore/exp/datavore/public/S1B/S1B_WV_SLC__1SSV_20170106T105022_20170106T110548_003726_006671_84D5.SAFE/s1b-wv1-slc-vv-20170106t110501-20170106t110504-003726-006671-061.tiff/S1B_WV_OCN__2SSV_20170106T105022_20170106T110548_003726_006671_55C0.SAFE/s1b-wv1-ocn-vv-20170106t110501-20170106t110504-003726-006671-061.nc/roughness/20170106110501/imageSentinel/