-
Notifications
You must be signed in to change notification settings - Fork 291
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
Ascat soilmoisture reader #1505
Conversation
update from source
Add composite / enhancements for scatterometry soil moisture data
DeepCode's analysis on #dff630 found:
Top issues
👉 View analysis in DeepCode’s Dashboard | Configure the bot |
Codecov Report
@@ Coverage Diff @@
## master #1505 +/- ##
==========================================
+ Coverage 88.08% 91.65% +3.57%
==========================================
Files 191 248 +57
Lines 29412 36171 +6759
==========================================
+ Hits 25907 33152 +7245
+ Misses 3505 3019 -486
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this reader, I have some comments...
logger = logging.getLogger('ASCATSOILMOISTUREBUFR') | ||
|
||
|
||
class ASCATSOILMOISTUREBUFR(BaseFileHandler): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use CamelCase for class names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
while True: | ||
# get handle for message | ||
bufr = ec.codes_bufr_new_from_file(fh) | ||
if bufr is None: | ||
break | ||
ec.codes_set(bufr, 'unpack', 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with bufr and eccodes, but will this read the file entirely? In which case, maybe the metadata and the data should be extracted in the same loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will read the whole file but the file is usually small. The only metadata is the start / end date. The bufr data (channels) are optional and I don't think it fits with the metadata so I would read this separately even if it means scanning the file twice.
years = np.resize(ec.codes_get_array(bufr, 'year'), size) | ||
months = np.resize(ec.codes_get_array(bufr, 'month'), size) | ||
days = np.resize(ec.codes_get_array(bufr, 'day'), size) | ||
hours = np.resize(ec.codes_get_array(bufr, 'hour'), size) | ||
minutes = np.resize(ec.codes_get_array(bufr, 'minute'), size) | ||
seconds = np.resize(ec.codes_get_array(bufr, 'second'), size) | ||
for year, month, day, hour, minute, second in zip(years, months, days, hours, minutes, seconds): | ||
time_stamp = datetime(year, month, day, hour, minute, second) | ||
date_min = time_stamp if not date_min else min(date_min, time_stamp) | ||
date_max = time_stamp if not date_max else max(date_max, time_stamp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be factorized into a separate method for clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I fixed this now, this has its own method.
return retmsg | ||
|
||
|
||
msg = create_message() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a constant, so I would use upper case MSG
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
self.assertTrue('start_time' in scn.attrs) | ||
self.assertTrue('end_time' in scn.attrs) | ||
self.assertTrue('sensor' in scn.attrs) | ||
self.assertTrue('scatterometer' in scn.attrs['sensor']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to check the actual values of the attributes to make sure they are interpreted correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added test for the values that are read from the file: start_time & end_time
from satpy import Scene | ||
fname = os.path.join(self.base_dir, FILENAME) | ||
scn = Scene(reader='ascat_l2_soilmoisture_bufr', filenames=[fname]) | ||
scn.load(scn.available_dataset_names()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about checking the result of the loading?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I check if all available dataset names are actually loaded.
@@ -0,0 +1,180 @@ | |||
#!/usr/bin/env python | |||
# -*- coding: utf-8 -*- | |||
# Copyright (c) 2017-2019 Satpy developers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's 2021 now :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
@@ -0,0 +1,122 @@ | |||
#!/usr/bin/env python | |||
# -*- coding: utf-8 -*- | |||
# Copyright (c) 2019 Satpy developers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2021!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
lat, lon = np.meshgrid(np.linspace(63, 65, nlat), np.linspace(-30, -20, nlon)) | ||
lat = np.round(np.ravel(lat), 4) | ||
lon = np.round(np.ravel(lon), 4) | ||
rstate=np.random.RandomState(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E225 missing whitespace around operator
I think all fixes are in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for adding the reader!
Reads Eumetsats soil moisture bufr message based on scatterometry data.
Tests are coming soon.
flake8 satpy
AUTHORS.md
if not there already