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

minor corrections on ascat driver #18

Open
wants to merge 10 commits into
base: pre-master
Choose a base branch
from
2 changes: 1 addition & 1 deletion doc/source/pp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Adding a new satellite: configuration file
A satellite configuration file looks like the following (here meteosat 7, mviri
instrument):

.. literalinclude:: ../../../mpop-smhi/etc/meteosat07.cfg
.. literalinclude:: ../../../satprod/etc/meteosat07.cfg
:language: ini
:linenos:

Expand Down
62 changes: 62 additions & 0 deletions etc/metop.ASCAT.cfg.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
##Rename this file to metop.cfg to read ASCAT data
[satellite]
satname = metop
variant =
number = ''
instruments = ('ascat',)

[ascat-level2]
filename = W_XX-EUMETSAT-Darmstadt,SURFACE+SATELLITE,METOPA+ASCAT_C_EUMP_%Y%m%d%H%M%S_%(orbit)s_eps_o_125_ssm_l2.nc
dir = ~/eumetsat/data
format = ascat_nc

[ascat-1]
name = 'soil_moisture'

[ascat-2]
name = 'soil_moisture_error'

[ascat-3]
name = 'soil_moisture_sensitivity'

[ascat-4]
name = 'mean_soil_moisture'

[ascat-5]
name = 'sigma40'

[ascat-6]
name = 'slope40_error'

[ascat-7]
name = 'dry_backscatter'

[ascat-8]
name = 'rainfall_flag'

[ascat-9]
name = 'wet_backscatter'

[ascat-10]
name = 'corr_flags'

[ascat-11]
name = 'proc_flag1'

[ascat-12]
name = 'proc_flag2'

[ascat-13]
name = 'aggregated_quality_flag'

[ascat-14]
name = 'snow_cover_probability'

[ascat-15]
name = 'frozen_soil_probability'

[ascat-16]
name = 'wetland_flag'

[ascat-17]
name = 'topography_flag'
75 changes: 75 additions & 0 deletions mpop/satin/ascat_nc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2014 Abhay Devasthale and Martin Raspaud

# Author(s):

# Martin Raspaud <[email protected]>
# Adam Dybbroe <[email protected]>
# Sajid Pareeth <[email protected]>

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Loader for ascat, netcdf format.
The driver works for netcdf format of ASCAT soil moisture swath data downloaded from
here: http://navigator.eumetsat.int/discovery/Start/DirectSearch/DetailResult.do?f%28r0%29=EO:EUM:DAT:METOP:SOMO12
rename the CONFIG file mpop/mpop/etc/metop.ascat.cfg.template to metop.cfg to read the ASCAT data
"""
import numpy as np
from ConfigParser import ConfigParser
from mpop import CONFIG_PATH
import os

from netCDF4 import Dataset


def load(satscene):
"""Load ascat data.
"""

# Read config file content
conf = ConfigParser()
conf.read(os.path.join(CONFIG_PATH, satscene.fullname + ".cfg"))
values = {"orbit": satscene.orbit,
"satname": satscene.satname,
"number": satscene.number,
"instrument": satscene.instrument_name,
"satellite": satscene.fullname
}
filename = os.path.join(
conf.get("ascat-level2", "dir"),
satscene.time_slot.strftime(conf.get("ascat-level2",
"filename",
raw=True)) % values)
# Load data from netCDF file
ds = Dataset(filename, 'r')
for chn_name in satscene.channels_to_load:
# Read variable corresponding to channel name
data = np.ma.masked_array(ds.variables[chn_name][:],np.isnan(ds.variables[chn_name][:]))
satscene[chn_name] = data
lons = ds.variables['longitude'][:]
lats = ds.variables['latitude'][:]

# Set scene area as pyresample geometry object
try:
from pyresample import geometry
satscene.area = geometry.SwathDefinition(lons=lons, lats=lats)
except ImportError:
# pyresample not available. Set lon and lats directly
satscene.area = None
satscene.lat = lats
satscene.lon = lons


2 changes: 1 addition & 1 deletion mpop/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2013, 2014, 2015 Martin Raspaud
# Copyright (c) 2013 Martin Raspaud

# Author(s):

Expand Down