-
Notifications
You must be signed in to change notification settings - Fork 151
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
Unnamed df index is not handled by lasio in LASFile.set_data_from_df #463
Comments
Hi @eucalypt1 , Is it correct that there are 3 issues as follows:
THanks!, |
<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:1849297240;
mso-list-template-ids:-1;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
-->Hi DC, That is correct. Some of the issues maybe due, because I don’t understand the formatting that can be specified as a user when creating a LAS file and/or what formatting prior to writing the file impacts the final output – I have been experimenting but not very successful. Also, how does the las writer/lasio package deal with NaNs and vise versa with NULLs? As an example of formatting control, can the user specify a default data column width? I hope this clarifies, Thanks for all your work, Godfried Sent from Mail for Windows 10 From: DC SlagelSent: Saturday, May 1, 2021 9:14 AMTo: kinverarity1/lasioCc: eucalypt1; MentionSubject: Re: [kinverarity1/lasio] Dataframe issue and formatting issue (#463) Hi @eucalypt1 ,Is it correct that there are 3 issues as follows:The previous (old) data section shouldn't be added to the ~Other section.NULL values should use the same number format as other numbers in the ~ASCII section.How to change the number format in the ~ASCII sectionTHanks!,DC—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
Virus-free. www.avast.com
|
For This a good quick tutorial that covers the string-to-numbers formatting: Here is an example usage. The
There default settings are:
Excerpt from the documentation on the write() function:
|
<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
code
{mso-style-priority:99;
font-family:"Courier New";}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
font-size:10.0pt;
font-family:"Courier New";}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";}
MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
-->Thanks for that, I must have missed it – so stupid of me. You look for one thing in the docs and miss the other. Regarding the ‘_ other’ issue maybe it is related to this exception I often run into when coding. I have no idea what it refers to. In this code fragment, I try to resample a las file for the depth increment. Using df (data from original las) into las_df ( the resampled data frame): df=las_data.df() #old data frame cstart=las_data.well.STRT.value cstop=las_data.well.STOP.value cstep=0.1 #Update lasdata for new step #create new dept index dpt=cstart mdpt=[] #Create empty new depth curve while (dpt <= cstop): mdpt.append(dpt) dpt +=cstep dpt=round(dpt,1) #create new dataframe las_df=pd.DataFrame(index=mdpt,columns=df.columns) # fill in new data frame with updated curvedata olen=len(df.index) nlen=len(las_df.index) o_idx=0 o_dpt=df.index[o_idx] for dpt in las_df.index: if dpt<= o_dpt: for crv in las_df.columns: las_df.loc[dpt,crv]=df.loc[o_dpt,crv] else: o_idx +=1 o_dpt=df.index[o_idx] for crv in las_df.columns: las_df.loc[dpt,crv]=df.loc[o_dpt,crv] #update las_data for las_df las_data.set_data(las_df) It produces in visual studio the following exception: I tried to work around it by using statements such as the one below: for c_idx in range(35): #mnemonic=cdescrvs[c_idx] new_las.insert_curve(ix=c_idx, mnemonic=cdescrvs[c_idx], data=np.array(mlist[c_idx]), unit= c_units[c_idx], descr=c_descr[c_idx], value='') Sent from Mail for Windows 10 From: DC SlagelSent: Saturday, May 1, 2021 12:11 PMTo: kinverarity1/lasioCc: eucalypt1; MentionSubject: Re: [kinverarity1/lasio] Dataframe issue and formatting issue (#463) For How to change the number format in the ~ASCII section, there are 2 parameters that can be passed into to the write function: fmt and column_fmt. These use python's string formatting language.Here is an example usage. Thelas.write("example.las", fmt='%.2f', column_fmt={0: '%.3f'}, version=2.0)There default settings are: fmt="%.5f", column_fmt=None,Excerpt from the documentation on the write() function: fmt (str): Python string formatting operator for numeric data to be used. column_fmt (dict or None): use this to set a different format string for specific columns from the data ndarray. E.g. to use ``'%.3f'`` for the depth column and ``'%.2f'`` for all the other columns, you would use ``fmt='%.2f', column_fmt={0: '%.3f'}``.—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
Virus-free. www.avast.com
|
<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
code
{mso-style-priority:99;
font-family:"Courier New";}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
font-size:10.0pt;
font-family:"Courier New";}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";}
MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
-->Thank you so much, I should have read the documentation better. But there are so many aspects to consider when writing las files, this one escaped.The formatting works great. Also, I found a workaround to the inadvertently inserted ‘~other’ data. Before saving into a LASfile, I simply remove this data using the following statement:las_data.other=’’Still… GodfriedSent from Mail for Windows 10 From: DC SlagelSent: Saturday, May 1, 2021 12:11 PMTo: kinverarity1/lasioCc: eucalypt1; MentionSubject: Re: [kinverarity1/lasio] Dataframe issue and formatting issue (#463) For How to change the number format in the ~ASCII section, there are 2 parameters that can be passed into to the write function: fmt and column_fmt. These use python's string formatting language.Here is an example usage. Thelas.write("example.las", fmt='%.2f', column_fmt={0: '%.3f'}, version=2.0)There default settings are: fmt="%.5f", column_fmt=None,Excerpt from the documentation on the write() function: fmt (str): Python string formatting operator for numeric data to be used. column_fmt (dict or None): use this to set a different format string for specific columns from the data ndarray. E.g. to use ``'%.3f'`` for the depth column and ``'%.2f'`` for all the other columns, you would use ``fmt='%.2f', column_fmt={0: '%.3f'}``.—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
Virus-free. www.avast.com
|
Hi @eucalypt1 thanks for raising these issues. Apologies on my behalf for the documentation, it is not that easy to find relevant information! I'm unclear on how the problem arose with data being written to the ~Other section, although it sounds like you have resolved that. If you are able to post a minimal working example, I'll have a look for you. Also, would you be able to reply (or edit previous comments) by using a web browser (#463), rather than replying through your email client? It's quite difficult to understand your messages because the email client is unfortunately modifying them. |
Sorry, about the gabblecook when trying to show some code in my emails. I didn't realize it all showed up here on github. I am such a Newby! Anyway, it seems that with your input I resolved the formatting issue. When trying to write a resampling function, I got similar problems when writing lasfiles. I created a dataframe of curves that I then updated in the lasfile using lasfile.set_data(df). I ran into a similar exception as showed up in my special application lasfile function discussed above. The exeption message states that it couldn't use the 'strip' attribute. (Sorry I lost the screenshot of the error message), which happened in the Lasio Library) Below is the resampling code now 'corrected'. It turned out that Lasio doesn't 'like' an un-named depth index in the dataframe. I had to specifically state: las_df.index.name='DEPT' With that my problems have dissappeared. So now everything is running hanky dory. #create new dept index
The NaN issue seems to be taken care of as follows:
Thank you for your help. Much appreciated |
Thanks for the update @eucalypt1 Note to myself: set_data_from_df should handle the case where the df index is unnamed. |
Thank you for updata 2.9
I have been using Python3 and the lasio 2.8 library to create special purpose lasfiles
I added data curves and used las_data.set_data(new_df) prior to overwriting an existing lasfile using new_las.write(new_File, version=2.0)
The saved las file shows the old data section in the ~Other section (blows me away)
1257.3 17.4 -9999.25 7 9 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25
1257.4 17.5 -9999.25 7 9 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25
1257.5 17.6 -9999.25 7 9 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25
1257.6 17.7 -9999.25 7 9 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25
1257.7 17.8 -9999.25 7 9 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25
1257.8 17.9 -9999.25 7 9 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25
1257.9 18.0 -9999.25 7 9 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25
1258.0 18.1 -9999.25 7 9 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25
1258.1 18.2 -9999.25 7 9 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25
1258.2 18.3 -9999.25 7 9 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25
~ASCII -----------------------------------------------------
and the updated data in the ~ASCII section. The file counts 47 curves over a relatively small depth intervalL
~ASCII -----------------------------------------------------
1240.00000 0.10000 -9999.25 3.00000 1.00000 1.00000 415.00000 91.82000 3.44500 0.00000 23.01950 0.00000 0.00000 0.00000 3.00000 3.50000 4.00000 0.00000 18.00000 22.00000 71.50000 2.58000 2.00000 -9999.25 23.01950 29.51950 51.51950 71.42130 27.51950 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 1.00000 1240.08000 0.10000 40.10000 -9999.25000 0.63000 0.18900 2660.00000 2160.00000 0.13700 0.35100 FD0001
1240.10000 0.20000 -9999.25 3.00000 1.00000 -9999.25 15.00000 78.00000 3.68040 0.00000 23.01950 0.00000 0.00000 0.00000 3.00000 3.50000 4.00000 0.00000 18.00000 22.00000 71.50000 2.58000 2.00000 -9999.25 23.01950 29.51950 51.51950 71.42130 27.51950 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 -9999.25 1.00000 1240.18000 0.12000 7.17000 1.83000 0.12000 0.16700 2700.00000 2250.00000 0.00100 0.42600 FD0002
1240.20000 0.30000 1.00000 3.00000 1.00000 11.00000 4.00000 91.82000 3.44500 0.00000 23.01950 0.00000 0.00000 0.00000 1.00000 3.50000 4.00000 0.00000 18.00000 22.00000 73.50000 2.58000 2.00000 -9999.25 23.01950 27.51950 49.51950 71.42130 27.51950 -9999.25 22.00000 27.51950 -9999.25 -9999.25 -9999.25 1.00000 1240.30000 0.25000 57.10000 56.10000 16.70000 0.18100 2680.00000 2190.00000 0.15700 0.27700 FD0003
1240.30000 0.40000 -9999.25 3.00000 1.00000 -9999.25 4.00000 91.00000 3.45800 0.00000 23.01950 0.00000 0.00000 0.00000 1.00000 3.50000 4.00000 0.00000 18.00000 22.00000 73.50000 2.58000 2.00000 -9999.25 23.01950 27.51950 49.51950 71.42130 27.51950 -9999.25 22.00000 27.51950 -9999.25 -9999.25 -9999.25 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000
1240.40000 0.50000 -9999.25 3.00000 1.00000 -9999.25 -9999.25 91.00000 3.45800 0.00000 23.01950 0.00000 0.00000 0.00000 1.00000 3.50000 4.00000 0.00000 18.00000 22.00000 73.50000 2.58000 2.00000 -9999.25 23.01950 27.51950 49.51950 71.42130 27.51950 -9999.25 22.00000 27.51950 -9999.25 -9999.25 -9999.25 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000
1240.50000 0.60000 -9999.25 3.00000 1.00000 -9999.25 4.00000 91.00000 3.45800 0.00000 23.01950 0.00000 0.00000 0.00000 1.00000 3.50000 4.00000 0.00000 18.00000 22.00000 73.50000 2.58000 2.00000 -9999.25 23.01950 27.51950 49.51950 71.42130 27.51950 -9999.25 22.00000 22.91560 -9999.25 -9999.25 -9999.25 1.00000 1240.55000 0.25000 45.70000 41.20000 4.68000 0.20100 2660.00000 2120.00000 0.12400 0.34500 FD0004
1240.60000 0.70000 -9999.25 3.00000 1.00000 -9999.25 430.00000 91.00000 3.45800 0.00000 23.01950 0.00000 0.00000 0.00000 1.00000 3.50000 4.00000 0.00000 18.00000 22.00000 73.50000 2.58000 2.00000 -9999.25 23.01950 27.51950 49.51950 71.42130 27.51950 -9999.25 22.00000 18.31170 -9999.25 -9999.25 -9999.25 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000
1240.70000 0.80000 -9999.25 3.00000 3.00000 -9999.25 -9999.25 15.00000 6.05890 0.00000 0.00000 0.00000 0.00000 0.00000 1.00000 0.00000 4.00000 0.00000 18.00000 22.00000 77.00000 2.58000 2.00000 -9999.25 0.00000 1.00000 23.00000 78.00000 4.50000 -9999.25 28.08000 13.70780 -9999.25 -9999.25 -9999.25 1.00000 1240.80000 0.35000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 DE0000
1240.80000 0.90000 -9999.25 3.00000 3.00000 -9999.25 -9999.25 15.00000 6.05890 0.00000 0.00000 0.00000 0.00000 0.00000 1.00000 0.00000 4.00000 0.00000 18.00000 22.00000 77.00000 2.58000 2.00000 -9999.25 0.00000 1.00000 23.00000 78.00000 4.50000 -9999.25 33.40000 9.10390 -9999.25 -9999.25 -9999.25 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000
1240.90000 1.00000 -9999.25 3.00000 3.00000 33.00000 110122.00000 15.00000 6.05890 0.00000 0.00000 0.00000 0.00000 0.00000 1.00000 0.00000 4.00000 80.00000 18.00000 52.40000 47.40000 2.58000 2.00000 -9999.25 0.00000 0.20000 52.60000 47.60000 4.50000 -9999.25 33.40000 9.10000 -9999.25 -9999.25 -9999.25 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000
1241.00000 1.10000 -9999.25 3.00000 3.00000 33.00000 1101.00000 15.00000 6.05890 0.00000 0.00000 0.00000 0.00000 0.00000 1.00000 0.00000 4.00000 70.00000 18.00000 48.60000 51.10000 2.58000 2.00000 -9999.25 0.00000 0.30000 48.90000 51.40000 4.50000 -9999.25 32.80000 13.70000 -9999.25 -9999.25 -9999.25 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000 -9999.25000
1241.10000 1.20000 -9999.25 3.00000 1.00000 -9999.25 3204.00000 91.00000 3.45800 0.00000
What do I do wrong for the old data to show up in the ~other section --- or is it a bug?
And although the ~ASCII section data is complete, I am unsure how to control the width of the data columns, especially when NULLs are involved. I have tried rounding the values before saving them but the results are all over the place. Any suggestions?
The text was updated successfully, but these errors were encountered: