<jupyter_start><jupyter_text>EUMETSATThe following example show how to read ASCAT Level 1b and Level 2 data in various formats (BUFR, EPS Native, netCDF). The data has been ordered from the EUMETSAT Data Centre (https://eoportal.eumetsat.int).  ASCAT Level 1b Read Level 1b BUFR file returning generic format<jupyter_code>import os
import cartopy
from datetime import datetime
import matplotlib.pyplot as plt

from ascat.eumetsat.level1 import AscatL1bFile
from ascat.eumetsat.level1 import AscatL1bBufrFile
from ascat.eumetsat.level1 import AscatL1bBufrFileList
from ascat.eumetsat.level1 import AscatL1bNcFile
from ascat.eumetsat.level1 import AscatL1bNcFileList
from ascat.eumetsat.level1 import AscatL1bEpsFile
from ascat.eumetsat.level1 import AscatL1bEpsFileList
from ascat.eumetsat.level1 import AscatL1bHdf5File
from ascat.eumetsat.level1 import AscatL1bHdf5FileList
path = os.path.join('..', 'tests','ascat_test_data', 'eumetsat',
                    'ASCAT_generic_reader_data')
filename = os.path.join(path, 'bufr',
                        'M02-ASCA-ASCSZR1B0200-NA-9.1-20100609013900.000000000Z-20130824233100-1280350.bfr')

bufr_file = AscatL1bFile(filename)
data = bufr_file.read()
data
plot_crs = cartopy.crs.PlateCarree()
data_crs = cartopy.crs.PlateCarree()

fig = plt.figure(figsize=(12, 6))
ax = fig.add_subplot(1, 1, 1, projection=plot_crs)
ax.set_title('Level 1 BUFR example - Sigma0 Fore Beam')

ax.add_feature(cartopy.feature.COASTLINE, linestyle='-')
ax.add_feature(cartopy.feature.BORDERS, linestyle=':')
ax.add_feature(cartopy.feature.LAND, facecolor='#aaaaaa')

float32_nan = -999999.
valid = data['sig'][:, 0] != float32_nan

sc = ax.scatter(data['lon'][valid], data['lat'][valid], 
                c=data['sig'][valid, 0], zorder=3, marker='s', s=2,
                transform=data_crs)

cax = fig.add_axes([ax.get_position().x1+0.01, ax.get_position().y0,
                    0.02, ax.get_position().height])
cbar = fig.colorbar(sc, ax=ax, cax=cax)
cbar.set_label('Backscatter [dB]')<jupyter_output><empty_output><jupyter_text>Read Level 1b BUFR file returning original format<jupyter_code>bufr_file = AscatL1bBufrFile(filename)
data = bufr_file.read()
data
plot_crs = cartopy.crs.PlateCarree()
data_crs = cartopy.crs.PlateCarree()

fig = plt.figure(figsize=(12, 6))
ax = fig.add_subplot(1, 1, 1, projection=plot_crs)
ax.set_title('Level 1 BUFR example - Sigma0 Fore Beam')

ax.add_feature(cartopy.feature.COASTLINE, linestyle='-')
ax.add_feature(cartopy.feature.BORDERS, linestyle=':')
ax.add_feature(cartopy.feature.LAND, facecolor='#aaaaaa')

bufr_nan = 1.7e+38
valid = data['m_Backscatter'] != bufr_nan

sc = ax.scatter(data['lon'][valid], data['lat'][valid], 
                c=data['m_Backscatter'][valid], zorder=3, marker='s', s=2,
                transform=data_crs)

cax = fig.add_axes([ax.get_position().x1+0.01, ax.get_position().y0,
                    0.02, ax.get_position().height])
cbar = fig.colorbar(sc, ax=ax, cax=cax)
cbar.set_label('Backscatter [dB]')<jupyter_output><empty_output><jupyter_text>Read Level 1b BUFR file using a timestamp<jupyter_code>bufr_path = os.path.join(path, 'bufr')

bufr_file_list = AscatL1bBufrFileList(bufr_path)
data = bufr_file_list.read(datetime(2010, 6, 9, 1, 39, 0))
data<jupyter_output><empty_output><jupyter_text>Read Level 1b EPS Native file returning original format<jupyter_code>filename = os.path.join(path, 'eps_nat',
                        'ASCA_SZR_1B_M02_20100609013900Z_20100609032058Z_R_O_20130824233100Z.nat')
eps_file = AscatL1bEpsFile(filename)
data = eps_file.read()
data<jupyter_output><empty_output><jupyter_text>Read Level 1b NetCDF file returning original format<jupyter_code>filename = os.path.join(path, 'nc',
                        'W_XX-EUMETSAT-Darmstadt,SURFACE+SATELLITE,METOPA+ASCAT_C_EUMP_20100609013900_18872_eps_o_125_l1.nc')

nc_file = AscatL1bNcFile(filename)
data = nc_file.read()
data<jupyter_output>/home/shahn/shahn/swdvlp/ascat/src/ascat/read_native/nc.py:105: UserWarning: WARNING: valid_max not used since it
cannot be safely cast to variable data type
  var_data = fid.variables[var_name][:].filled(fill_value)<jupyter_text>ASCAT Level 2 Read Level 2 BUFR file returning generic format<jupyter_code>import os
import cartopy
from datetime import datetime
import matplotlib.pyplot as plt

from ascat.eumetsat.level2 import AscatL2File
from ascat.eumetsat.level2 import AscatL2BufrFile
from ascat.eumetsat.level2 import AscatL2BufrFileList
from ascat.eumetsat.level2 import AscatL2NcFile
from ascat.eumetsat.level2 import AscatL2NcFileList
from ascat.eumetsat.level2 import AscatL2EpsFile
from ascat.eumetsat.level2 import AscatL2EpsFileList
path = os.path.join('..', 'tests','ascat_test_data', 'eumetsat')
bufr_path = os.path.join(path, 'ASCAT_L2_SM_125', 'bufr', 'Metop_B')
filename = os.path.join(bufr_path, 'M01-ASCA-ASCSMR02-NA-5.0-20170220050900.000000000Z-20170220055833-1207110.bfr')
bufr_file = AscatL2File(filename)
data = bufr_file.read()
data
plot_crs = cartopy.crs.PlateCarree()
data_crs = cartopy.crs.PlateCarree()

fig = plt.figure(figsize=(12, 6))
ax = fig.add_subplot(1, 1, 1, projection=plot_crs)
ax.set_title('Level 2 BUFR example - Soil moisture')

ax.add_feature(cartopy.feature.COASTLINE, linestyle='-')
ax.add_feature(cartopy.feature.BORDERS, linestyle=':')
ax.add_feature(cartopy.feature.LAND, facecolor='#aaaaaa')

field = 'sm'
float32_nan = -999999.
valid = data[field] != float32_nan

sc = ax.scatter(data['lon'][valid], data['lat'][valid], 
                c=data[field][valid], zorder=3, marker='s', s=2,
                transform=data_crs)

cax = fig.add_axes([ax.get_position().x1+0.01, ax.get_position().y0,
                    0.02, ax.get_position().height])
cbar = fig.colorbar(sc, ax=ax, cax=cax)
cbar.set_label('Soil moisture [%]')<jupyter_output><empty_output><jupyter_text>Read Level 2 BUFR file returning original format<jupyter_code>bufr_file = AscatL2BufrFile(filename)
data = bufr_file.read()
data<jupyter_output><empty_output><jupyter_text>Read Level 2 BUFR file using a timestamp<jupyter_code>bufr_path = os.path.join(path, 'ASCAT_L2_SM_125', 'bufr', 'Metop_B')
bufr_file = AscatL2BufrFileList(bufr_path, sat='B')
data = bufr_file.read(datetime(2017, 2, 20, 5, 9, 0))
data<jupyter_output><empty_output><jupyter_text>Read Level 2 EPS Native file returning original format<jupyter_code>eps_path = os.path.join(path, 'ASCAT_generic_reader_data', 'eps_nat')
filename = os.path.join(eps_path, 'ASCA_SMO_02_M01_20180612035700Z_20180612053856Z_N_O_20180612044530Z.nat')
eps_file = AscatL2EpsFile(filename)
data = eps_file.read()
data<jupyter_output><empty_output><jupyter_text>Read Level 2 NetCDF file returning original format<jupyter_code>nc_path = os.path.join(path, 'ASCAT_generic_reader_data', 'nc')
filename = os.path.join(nc_path, 'W_XX-EUMETSAT-Darmstadt,SURFACE+SATELLITE,METOPB+ASCAT_C_EUMP_20180612035700_29742_eps_o_250_ssm_l2.nc')
nc_file = AscatL2NcFile(filename)
data = nc_file.read()
data<jupyter_output>/home/shahn/shahn/swdvlp/ascat/src/ascat/read_native/nc.py:105: UserWarning: WARNING: valid_max not used since it
cannot be safely cast to variable data type
  var_data = fid.variables[var_name][:].filled(fill_value)
{'fraction_non_alphanumeric': 0.12423568649249583, 'fraction_numerical': 0.057115063924402444, 'mean_word_length': 5.802457466918715, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '192227', 'license': 'MIT', 'n_tokens_mistral': 3086, 'n_tokens_neox': 2839, 'n_words': 488, 'path': 'docs/read_eumetsat.ipynb', 'repo_name': 'fabiodelogu/ascat', 'size': '7196'}