Open daniel-sol opened 3 years ago
Hi and thanks for the bug report! Just to make sure I understand your problem, would this well replicate it?
1.01
Unknown
OP_1 0 0 0
2
Zonelog DISC 1 zone1 2 zone2 3 zone3
Perm UNK lin
0 0 0 nan -999 -999
1 1 1 nan 0.1
2 2 2 nan 0.2
3 3 3 nan 0.3
4 4 4 nan 0.4
5 5 5 nan 0.5
where Zonelog only has nan
?
Yes, should do. At least according to my understanding..
Sendt fra min iPhone
- sep. 2021 kl. 14:39 skrev Øyvind Eide @.***>:
Hi and thanks for the bug report! Just to make sure I understand your problem, would this well replicate it?
1.01 Unknown OP_1 0 0 0 2 Zonelog DISC 1 zone1 2 zone2 3 zone3 Perm UNK lin 0 0 0 nan -999 -999 1 1 1 nan 0.1 2 2 2 nan 0.2 3 3 3 nan 0.3 4 4 4 nan 0.4 5 5 5 nan 0.5 where Zonelog only has nan?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
This seems not to have anything with Nan values to do, but that the codenames array is empty:
import xtgeo
import numpy as np
w = xtgeo.well_from_roxar(project, "55_33-1")
print(w.dataframe)
w.to_roxar(project, "55_33-1")
w.dataframe["Zone"] = np.nan
print(w.dataframe["Zone"].max())
w.to_roxar(project, "55_33-1")
OK
but:
import xtgeo
import numpy as np
w = xtgeo.well_from_roxar(project, "55_33-2")
print(w.dataframe)
w.to_roxar(project, "55_33-2")
w.dataframe["Zone"] = np.nan
print(w.dataframe["Zone"].max())
w.to_roxar(project, "55_33-2")
w.set_logrecord("Zone", {}) # <<<<<
w.to_roxar(project, "55_33-2")
ValueError: Attempt to assign empty codenames array.
This may happen in RMS if no codename array/dict is received (since all values are Nan) The workaround is to set it some something dummy
w.set_logrecord("Zone", {0: "dummy"}) # <<<<<
w.to_roxar(project, "55_33-2")
However, a better way in xtgeo is needed here (perhaps to make a dummy codenames dict and raise a warning?)
Thanks for clarification!
However, a better way in xtgeo is needed here (perhaps to make a dummy codenames dict and raise a warning?)
I guess our course of action should depend on how RMS views this, is it perfectly valid in RMS or should it be considered an error? If the latter we should just raise an exception if it is ever set to an empty dict. If the first is the case, can we skip setting the codenames, would that still be valid? Would be better to not create a dummy value I think, as a round trip RMS -> xtgeo -> RMS should not change anything.
It seems that the Roxar API errors on empty dicts:
well = project.wells['55_33-3']
wb = well.wellbore
traj = wb.trajectories['Drilled trajectory']
log_run = traj.log_runs['log']
log_curves = log_run.log_curves
zon = log_curves['Zone']
print(zon.get_values())
print(zon.get_code_names())
zon.set_code_names({})
[0 0 0 ... 4 4 4]
{0: 'Above', 1: 'Valysar', 2: 'Therys', 3: 'Volon', 4: 'Below'}
Traceback (most recent call last):
Python script, line 16
ValueError: Attempt to assign empty codenames array.
I find this actually a bug in the Roxar API since get_code_names()
can return an empty dict, but this is not accepted in set_code_names()
If that is the case I would argue for:
try:
thelog.set_code_names(codedict)
except ValueError as err:
raise ValueError(f"Unable to export due to empty condenames array for property: {lname}") from err
then we can give good feedback when it fails at least. Then the user is able to add a property and export again.
We could also add a warning to the property setter if the user does this. How likely is it that we can make Roxar change how it behaves?
I agree with the solution you propose. I will send Emerson/Roxar a bug issue but I expect no quick fix.
When there exists a discrete log with only nan in log, one cannot store dataframe back using the dataframe setter.