Giter Site home page Giter Site logo

Comments (6)

ErlendHaa avatar ErlendHaa commented on July 24, 2024 1

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.

ErlendHaa avatar ErlendHaa commented on July 24, 2024

Is this perhaps a Pandas error?

from dlisio.

AchyuthB avatar AchyuthB commented on July 24, 2024

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.
image

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.

AchyuthB avatar AchyuthB commented on July 24, 2024

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.

ErlendHaa avatar ErlendHaa commented on July 24, 2024

Yes, they are the same thing. At least conceptually.

from dlisio.

AchyuthB avatar AchyuthB commented on July 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.