Comments (6)
There is nothing wrong with the data, nor the formatting of it. The returned array from lis.curves
is as expected. The thing is that one or more of the curves in the file contains non-scalar sample values. I.e. each depth sample is an array of data - instead of a single value. A practical example would be an image-curve. numpy handles this completely fine, but pandas is made for strictly tabular data and nested structures aren't allowed (hence the "not 1 dimensional" error).
If you are force to work with Pandas and not numpy you could:
[1] drop the non-scalar curves before creating the dataframe (check the numpy.dtype of each curve)
[2] expand each sample-array into one column pr sample. I know people do this, but honestly it creates a mess and would advice against it.
If you want to work with these none-scalar curves I strongly suggest sticking to numpy, because it handles the complexity of the data structure just fine without any weird transformations.
from dlisio.
Is this perhaps a Pandas error?
from dlisio.
Hi @ErlendHaa,
Yes, you are right. It is Pandas error. I am trying to transpose the set of data returned by lis.curves(). Sometimes, the transpose fails, because the data returned by lis..curves() is not in the expected format. I was just wondering if there was any means to format the data returned by lis.curves() so that it can be transposed.
Below is the screen shot of working and error data. Both belongs to the same lis file.
Code snippet
def extract_curve_data(logical_file_index, format_spec_index, logical_file, format_spec):
try:
for sample_rate in g_sample_rates:
curves = lis.curves(logical_file, format_spec, sample_rate=sample_rate, strict=False)
if len(curves) == 0:
log_debug(" - Script Info: No curve data available for format_spec with index " + str(format_spec_index) + " and sample_rate " + str(sample_rate))
continue
curves_data = pd.DataFrame(curves).T
except Exception as e:
log_debug(" - Script Warn: While processing curve data - " + str(e))
Output
- Script Info: Processing physical file :: D:\FeedFiles\LIS\/205_27-_2_dwl__1631147.lis
- Script Info: Extracting data for logical file :: FBSTB .005
- Script Info: No curve data available for format_spec with index 0 and sample_rate 1
- Script Info: No curve data available for format_spec with index 0 and sample_rate 60
- Script Info: No curve data available for format_spec with index 0 and sample_rate 4
- Script Warn: While processing curve data - Data must be 1-dimensional
from dlisio.
Hi @ErlendHaa,
Thank you for explaining this in detail.
The non-scalar curves look like the multi-dimensional ones in DLIS.
Regards,
Achyuth
from dlisio.
Yes, they are the same thing. At least conceptually.
from dlisio.
Hi,
I somehow managed to seperate and extract the single and multi dimensional curve data from the LIS files.
I know this is not the perfect solution. Will work on improving the code. :-)
def seperate_curve_data(curves):
# curves = lis.curves(logical_file, format_spec, sample_rate=sample_rate, strict=False)
multi_dim_curves = []
single_dim_curves = []
curves_meta = curves.dtype.names
for row_values in curves:
multi_dim_curve = list()
single_dim_curve = list()
multi_dim_index = list()
single_dim_index = list()
multi_spec_blocks = list()
single_spec_blocks = list()
i=0
for curve in row_values:
if len(np.shape(curve)) > 0 and len((curve)) > 1:
multi_dim_curve.append(tuple(curve))
multi_dim_index.append(i)
else:
single_dim_curve.append(curve)
single_dim_index.append(i)
i = i + 1
multi_dim_curves.append(multi_dim_curve)
single_dim_curves.append(tuple(single_dim_curve))
single_curves = np.asarray(single_dim_curves)
for i in multi_dim_index:
multi_spec_blocks.append(list(curves_meta)[i])
for i in single_dim_index:
single_spec_blocks.append(list(curves_meta)[i])
return single_curves, single_spec_blocks, multi_dim_curves, multi_spec_blocks
from dlisio.
Related Issues (20)
- Missing "index_mnem" in the Data Format Specification Record (DFSR) HOT 5
- logical_file.data_format_specs() throwing AttributeError 'dlisio.core.lis_stream' object has no attribute 'read_records' HOT 8
- How to extract dlisio.lis.InformationRecord HOT 1
- One channel name is missing while extracting channels from logical_file HOT 5
- Extracting metadata (parameter) information from LIS files. HOT 7
- Building Dlisio on a Macbook M1 HOT 1
- pip install dlisio error HOT 1
- Incorrect format version in Visible Record HOT 2
- How to access header information in unstructured LIS files? HOT 2
- Version 0.3.6 will not build on Alpine 3.16/gcc 11.2.1 HOT 4
- Is there a way to write? HOT 2
- Feature request: DLISIO support reading from byte buffers
- Issue with installing from pip om M1 Mac HOT 5
- Accessing First & Last Reading of a Tool/Curves HOT 2
- Installation on Alpine linux HOT 3
- fshort data type help HOT 2
- DeprecationWarning: pkg_resources is deprecated as an API. HOT 1
- Add ability to skip record with invalid type HOT 1
- Working with multidimensional curves in DLIS files HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dlisio.