-
Notifications
You must be signed in to change notification settings - Fork 16
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
Update bufr.py for carra2 for local observations #35
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
213636c
Added features in bufr.py for carra2 to be able to read local observa…
PerDahlgren 3af9e20
Again, added features in bufr.py for carra2 to be able to read local …
PerDahlgren 5c77dfc
Do black and remove unused import
trygveasp a6d2f50
Added features in bufr.py for carra2 to be able to read local observa…
PerDahlgren 50122a1
Merge branch 'bufr_changes' of github.com:PerDahlgren/pysurfex into b…
PerDahlgren b26664e
Further updates to bufr.py
PerDahlgren e185bc8
Reformatted pysurfex/bufr.py
PerDahlgren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
"""bufr treatment.""" | ||
import logging | ||
import sys | ||
from math import exp | ||
|
||
import numpy as np | ||
|
@@ -86,6 +87,7 @@ def __init__( | |
"heightOfStation", | ||
"stationNumber", | ||
"blockNumber", | ||
"stationOrSiteName", | ||
] | ||
processed_threshold = 0 | ||
nerror = {} | ||
|
@@ -113,6 +115,10 @@ def __init__( | |
"/heightOfSensorAboveLocalGroundOrDeckOfMarinePlatform=1.5" | ||
"/dewpointTemperature" | ||
) | ||
keys.append( | ||
"/heightOfSensorAboveLocalGroundOrDeckOfMarinePlatform=2" | ||
"/relativeHumidity" | ||
) | ||
elif var == "airTemperatureAt2M": | ||
keys.append("airTemperatureAt2M") | ||
keys.append( | ||
|
@@ -171,7 +177,9 @@ def __init__( | |
stid = "NA" | ||
station_number = -1 | ||
block_number = -1 | ||
site_name = "NA" | ||
t2m = np.nan | ||
rh2m = np.nan | ||
td2m = np.nan | ||
s_d = np.nan | ||
temp = np.nan | ||
|
@@ -223,6 +231,8 @@ def __init__( | |
station_number = val | ||
if key == "blockNumber": | ||
block_number = val | ||
if key == "stationOrSiteName": | ||
site_name = val | ||
if key == "airTemperatureAt2M": | ||
t2m = val | ||
if ( | ||
|
@@ -234,6 +244,12 @@ def __init__( | |
"/airTemperature" | ||
): | ||
temp = val | ||
if ( | ||
key | ||
== "/heightOfSensorAboveLocalGroundOrDeckOfMarinePlatform=2" | ||
"/relativeHumidity" | ||
): | ||
rh2m = val | ||
if key == "dewpointTemperatureAt2M": | ||
td2m = val | ||
if ( | ||
|
@@ -279,24 +295,29 @@ def __init__( | |
if not exists: | ||
logging.debug("Pos does not exist %s %s", pos, var) | ||
if var == "relativeHumidityAt2M": | ||
if not np.isnan(t2m) and not np.isnan(td2m): | ||
if not np.isnan(t2m) and not np.isnan(td2m) and np.isnan(rh2m): | ||
try: | ||
value = self.td2rh(td2m, t2m) | ||
value = value * 0.01 | ||
value = value * 0.01 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the white-spaces |
||
except Exception: | ||
logging.debug("Got exception for %s:", var) | ||
value = np.nan | ||
elif not np.isnan(temp) and not np.isnan(t_d) and np.isnan(rh2m): | ||
try: | ||
value = self.td2rh(t_d, temp) | ||
value = value * 0.01 | ||
except Exception: | ||
logging.debug( | ||
"Got exception for %s", | ||
var, | ||
) | ||
value = np.nan | ||
else: | ||
if not np.isnan(temp) and not np.isnan(t_d): | ||
try: | ||
value = self.td2rh(t_d, temp) | ||
value = value * 0.01 | ||
except Exception: | ||
logging.debug( | ||
"Got exception for %s", | ||
var, | ||
) | ||
value = np.nan | ||
value = np.nan | ||
|
||
if np.isnan(value) and not np.isnan(rh2m): | ||
value = 0.01 * rh2m | ||
|
||
elif var == "airTemperatureAt2M": | ||
if np.isnan(t2m): | ||
if not np.isnan(temp): | ||
|
@@ -385,6 +406,9 @@ def __init__( | |
) | ||
if station_number > 0 and block_number > 0: | ||
stid = str((block_number * 1000) + station_number) | ||
if stid == "NA" and site_name != "NA" and site_name.isnumeric(): | ||
stid = site_name | ||
|
||
observations.append( | ||
Observation( | ||
obs_dtg, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 not needed?