Getting an Array of values from a data set.

Hey all:

Trying to take a dataset of float values and build an array that can be used to generate a raster. If i have code something like this:

*// Open up the dataset.
  H5DataSetId curDepthDataset = H5D.open(curHDF, curName1 + "/" + **curName2 **+ "/" + **curName3 **+ "/depth");
  H5ObjectWithAttributes curDepthAttObj = (H5ObjectWithAttributes)curDepthDataset;

// Create a Byte[] to hold the depth data.
H5DataTypeId datasetType = H5D.getType(curDepthDataset);
H5T.H5TClass datasetClass = H5T.getClass(datasetType);
H5DataTypeId datasetNativeType = H5T.getNativeType(datasetType, H5T.Direction.ASCEND);

int bufferSize = H5T.getSize(datasetNativeType);

System.Array buffer = System.Array.CreateInstance(Type.GetType("System.Byte"), bufferSize);
Byte[] bArray = HdfHelper.ConvertToBytes(buffer);

H5D.read(curDepthDataset, datasetNativeType, new H5Array<byte>(bArray));*

Why would this give me an error like this:

*FatalExecutionEngineError was detected*

*The runtime has encountered a fatal error. The address of the error was at 0x6b344243, on thread 0x334. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

*I am having no trouble using this method to read the attributes out of the individual groups.

Thanks,
DB

DB,

Why the 'round-about way of creating a byte array? Won't this work?
            byte[] buffer = new byte[bufferSize];

What's going on inside your HdfHelper.ConvertToBytes function?

Scott

···

From: hdf-forum-bounces@hdfgroup.org [mailto:hdf-forum-bounces@hdfgroup.org] On Behalf Of Donald Brandon
Sent: Thursday, September 15, 2011 11:45 AM
To: HDF Users Discussion List
Subject: [Hdf-forum] Getting an Array of values from a data set.

Hey all:

Trying to take a dataset of float values and build an array that can be used to generate a raster. If i have code something like this:

// Open up the dataset.
H5DataSetId curDepthDataset = H5D.open(curHDF, curName1 + "/" + curName2 + "/" + curName3 + "/depth");
H5ObjectWithAttributes curDepthAttObj = (H5ObjectWithAttributes)curDepthDataset;

// Create a Byte[] to hold the depth data.
H5DataTypeId datasetType = H5D.getType(curDepthDataset);
H5T.H5TClass datasetClass = H5T.getClass(datasetType);
H5DataTypeId datasetNativeType = H5T.getNativeType(datasetType, H5T.Direction.ASCEND);

int bufferSize = H5T.getSize(datasetNativeType);

System.Array buffer = System.Array.CreateInstance(Type.GetType("System.Byte"), bufferSize);
Byte[] bArray = HdfHelper.ConvertToBytes(buffer);

H5D.read(curDepthDataset, datasetNativeType, new H5Array<byte>(bArray));

Why would this give me an error like this:

FatalExecutionEngineError was detected

The runtime has encountered a fatal error. The address of the error was at 0x6b344243, on thread 0x334. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

I am having no trouble using this method to read the attributes out of the individual groups.

Thanks,
DB

________________________________
This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

Hey Scott:

Wouldn't that make my code look too simple? :wink:
Just kidding...

The ConvertToBytes method uses a StreamWriter and a MemoryStream to convert the array. I pulled this out and used your simpler method and it doesn't change the outcome of the code.

I have been putting in some long hours on this project and working when I am probably too tired to do so. Sometimes things just don't come to you and when you find a method that works, you don't question it much...

Thanks for your help.
DB

···

On 9/15/2011 11:00 AM, Mitchell, Scott - IS wrote:

DB,

Why the 'round-about way of creating a byte array? Won't this work?
byte[] buffer = newbyte[bufferSize];

What's going on inside your HdfHelper.ConvertToBytes function?

Scott

*From:*hdf-forum-bounces@hdfgroup.org [mailto:hdf-forum-bounces@hdfgroup.org] *On Behalf Of *Donald Brandon
*Sent:* Thursday, September 15, 2011 11:45 AM
*To:* HDF Users Discussion List
*Subject:* [Hdf-forum] Getting an Array of values from a data set.

Hey all:

Trying to take a dataset of float values and build an array that can be used to generate a raster. If i have code something like this:

*// Open up the dataset.
H5DataSetId curDepthDataset = H5D.open(curHDF, curName1 + "/" + curName2 + "/" + curName3 + "/depth");
H5ObjectWithAttributes curDepthAttObj = (H5ObjectWithAttributes)curDepthDataset;

// Create a Byte[] to hold the depth data.
H5DataTypeId datasetType = H5D.getType(curDepthDataset);
H5T.H5TClass datasetClass = H5T.getClass(datasetType);
H5DataTypeId datasetNativeType = H5T.getNativeType(datasetType, H5T.Direction.ASCEND);

int bufferSize = H5T.getSize(datasetNativeType);

System.Array buffer = System.Array.CreateInstance(Type.GetType("System.Byte"), bufferSize);
Byte[] bArray = HdfHelper.ConvertToBytes(buffer);

H5D.read(curDepthDataset, datasetNativeType, new H5Array<byte>(bArray));*

Why would this give me an error like this:

*FatalExecutionEngineError was detected*

*The runtime has encountered a fatal error. The address of the error was at 0x6b344243, on thread 0x334. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.**

*I am having no trouble using this method to read the attributes out of the individual groups.

Thanks,
DB

------------------------------------------------------------------------
This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

--
Donald Brandon
228-424-3958 (cell)
http://www.brandondl.com

Anybody else have any ideas on this?

Thanks,
DB

···

On 9/15/2011 11:30 AM, Donald Brandon wrote:

Hey Scott:

Wouldn't that make my code look too simple? :wink:
Just kidding...

The ConvertToBytes method uses a StreamWriter and a MemoryStream to convert the array. I pulled this out and used your simpler method and it doesn't change the outcome of the code.

I have been putting in some long hours on this project and working when I am probably too tired to do so. Sometimes things just don't come to you and when you find a method that works, you don't question it much...

Thanks for your help.
DB

On 9/15/2011 11:00 AM, Mitchell, Scott - IS wrote:

DB,

Why the 'round-about way of creating a byte array? Won't this work?
byte[] buffer = newbyte[bufferSize];

What's going on inside your HdfHelper.ConvertToBytes function?

Scott

*From:*hdf-forum-bounces@hdfgroup.org [mailto:hdf-forum-bounces@hdfgroup.org] *On Behalf Of *Donald Brandon
*Sent:* Thursday, September 15, 2011 11:45 AM
*To:* HDF Users Discussion List
*Subject:* [Hdf-forum] Getting an Array of values from a data set.

Hey all:

Trying to take a dataset of float values and build an array that can be used to generate a raster. If i have code something like this:

*// Open up the dataset.
H5DataSetId curDepthDataset = H5D.open(curHDF, curName1 + "/" + curName2 + "/" + curName3 + "/depth");
H5ObjectWithAttributes curDepthAttObj = (H5ObjectWithAttributes)curDepthDataset;

// Create a Byte[] to hold the depth data.
H5DataTypeId datasetType = H5D.getType(curDepthDataset);
H5T.H5TClass datasetClass = H5T.getClass(datasetType);
H5DataTypeId datasetNativeType = H5T.getNativeType(datasetType, H5T.Direction.ASCEND);

int bufferSize = H5T.getSize(datasetNativeType);

System.Array buffer = System.Array.CreateInstance(Type.GetType("System.Byte"), bufferSize);
Byte[] bArray = HdfHelper.ConvertToBytes(buffer);

H5D.read(curDepthDataset, datasetNativeType, new H5Array<byte>(bArray));*

Why would this give me an error like this:

*FatalExecutionEngineError was detected*

*The runtime has encountered a fatal error. The address of the error was at 0x6b344243, on thread 0x334. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.**

*I am having no trouble using this method to read the attributes out of the individual groups.

Thanks,
DB

------------------------------------------------------------------------
This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Is it a problem that you're reading a datasetNativeType, but putting it into a byte[]? If you read curDepthDataset into a buffer of datasetNativeType, does it work?

HDF5DotNet doesn't give you much in the way of error information. So you're often left poking around for a solution when it crashes or throws an exception.

Scott

···

From: hdf-forum-bounces@hdfgroup.org [mailto:hdf-forum-bounces@hdfgroup.org] On Behalf Of Donald Brandon
Sent: Thursday, September 15, 2011 9:02 PM
To: HDF Users Discussion List
Subject: Re: [Hdf-forum] Getting an Array of values from a data set.

Anybody else have any ideas on this?

Thanks,
DB

On 9/15/2011 11:30 AM, Donald Brandon wrote:
Hey Scott:

Wouldn't that make my code look too simple? :wink:
Just kidding...

The ConvertToBytes method uses a StreamWriter and a MemoryStream to convert the array. I pulled this out and used your simpler method and it doesn't change the outcome of the code.

I have been putting in some long hours on this project and working when I am probably too tired to do so. Sometimes things just don't come to you and when you find a method that works, you don't question it much...

Thanks for your help.
DB

On 9/15/2011 11:00 AM, Mitchell, Scott - IS wrote:
DB,

Why the 'round-about way of creating a byte array? Won't this work?
            byte[] buffer = new byte[bufferSize];

What's going on inside your HdfHelper.ConvertToBytes function?

Scott

From: hdf-forum-bounces@hdfgroup.org<mailto:hdf-forum-bounces@hdfgroup.org> [mailto:hdf-forum-bounces@hdfgroup.org] On Behalf Of Donald Brandon
Sent: Thursday, September 15, 2011 11:45 AM
To: HDF Users Discussion List
Subject: [Hdf-forum] Getting an Array of values from a data set.

Hey all:

Trying to take a dataset of float values and build an array that can be used to generate a raster. If i have code something like this:

// Open up the dataset.
H5DataSetId curDepthDataset = H5D.open(curHDF, curName1 + "/" + curName2 + "/" + curName3 + "/depth");
H5ObjectWithAttributes curDepthAttObj = (H5ObjectWithAttributes)curDepthDataset;

// Create a Byte[] to hold the depth data.
H5DataTypeId datasetType = H5D.getType(curDepthDataset);
H5T.H5TClass datasetClass = H5T.getClass(datasetType);
H5DataTypeId datasetNativeType = H5T.getNativeType(datasetType, H5T.Direction.ASCEND);

int bufferSize = H5T.getSize(datasetNativeType);

System.Array buffer = System.Array.CreateInstance(Type.GetType("System.Byte"), bufferSize);
Byte[] bArray = HdfHelper.ConvertToBytes(buffer);

H5D.read(curDepthDataset, datasetNativeType, new H5Array<byte>(bArray));

Why would this give me an error like this:

FatalExecutionEngineError was detected

The runtime has encountered a fatal error. The address of the error was at 0x6b344243, on thread 0x334. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

I am having no trouble using this method to read the attributes out of the individual groups.

Thanks,
DB

________________________________
This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

_______________________________________________

Hdf-forum is for HDF software users discussion.

Hdf-forum@hdfgroup.org<mailto:Hdf-forum@hdfgroup.org>

http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

_______________________________________________

Hdf-forum is for HDF software users discussion.

Hdf-forum@hdfgroup.org<mailto:Hdf-forum@hdfgroup.org>

http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Thanks, Scott.

Do you know off of the top of your head if there is a method to return the type of my "H5TypeId datasetNativeType"? I would have thought something like H5T.<SomeMethod> would return what the native type is.

DB

···

On 9/16/2011 9:04 AM, Mitchell, Scott - IS wrote:

Is it a problem that you're reading a datasetNativeType, but putting it into a byte[]? If you read curDepthDataset into a buffer of datasetNativeType, does it work?

HDF5DotNet doesn't give you much in the way of error information. So you're often left poking around for a solution when it crashes or throws an exception.

Scott

*From:*hdf-forum-bounces@hdfgroup.org [mailto:hdf-forum-bounces@hdfgroup.org] *On Behalf Of *Donald Brandon
*Sent:* Thursday, September 15, 2011 9:02 PM
*To:* HDF Users Discussion List
*Subject:* Re: [Hdf-forum] Getting an Array of values from a data set.

Anybody else have any ideas on this?

Thanks,
DB

On 9/15/2011 11:30 AM, Donald Brandon wrote:

Hey Scott:

Wouldn't that make my code look too simple? :wink:
Just kidding...

The ConvertToBytes method uses a StreamWriter and a MemoryStream to convert the array. I pulled this out and used your simpler method and it doesn't change the outcome of the code.

I have been putting in some long hours on this project and working when I am probably too tired to do so. Sometimes things just don't come to you and when you find a method that works, you don't question it much...

Thanks for your help.
DB

On 9/15/2011 11:00 AM, Mitchell, Scott - IS wrote:

DB,

Why the 'round-about way of creating a byte array? Won't this work?
byte[] buffer = newbyte[bufferSize];

What's going on inside your HdfHelper.ConvertToBytes function?

Scott

*From:*hdf-forum-bounces@hdfgroup.org <mailto:hdf-forum-bounces@hdfgroup.org> [mailto:hdf-forum-bounces@hdfgroup.org] *On Behalf Of *Donald Brandon
*Sent:* Thursday, September 15, 2011 11:45 AM
*To:* HDF Users Discussion List
*Subject:* [Hdf-forum] Getting an Array of values from a data set.

Hey all:

Trying to take a dataset of float values and build an array that can be used to generate a raster. If i have code something like this:

*// Open up the dataset.
H5DataSetId curDepthDataset = H5D.open(curHDF, curName1 + "/" + curName2 + "/" + curName3 + "/depth");
H5ObjectWithAttributes curDepthAttObj = (H5ObjectWithAttributes)curDepthDataset;

// Create a Byte[] to hold the depth data.
H5DataTypeId datasetType = H5D.getType(curDepthDataset);
H5T.H5TClass datasetClass = H5T.getClass(datasetType);
H5DataTypeId datasetNativeType = H5T.getNativeType(datasetType, H5T.Direction.ASCEND);

int bufferSize = H5T.getSize(datasetNativeType);

System.Array buffer = System.Array.CreateInstance(Type.GetType("System.Byte"), bufferSize);
Byte[] bArray = HdfHelper.ConvertToBytes(buffer);

H5D.read(curDepthDataset, datasetNativeType, new H5Array<byte>(bArray));*

Why would this give me an error like this:

*FatalExecutionEngineError was detected*

*The runtime has encountered a fatal error. The address of the error was at 0x6b344243, on thread 0x334. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.**

*I am having no trouble using this method to read the attributes out of the individual groups.

Thanks,
DB

------------------------------------------------------------------------

This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org <mailto:Hdf-forum@hdfgroup.org>
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org <mailto:Hdf-forum@hdfgroup.org>
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

--
Donald Brandon
228-424-3958 (cell)
http://www.brandondl.com

Thanks for making me think. Moving away from the byte array and going to the native type of the dataset fixed the problem. That and specifying the correct array size. I wasn't using the size of the dataset but rather the size of the type. Duh! i guess it is the little things that can get by you easily...

Thanks everyone, especially Scott on this one!

DB

···

On 9/16/2011 10:33 AM, Donald Brandon wrote:

Thanks, Scott.

Do you know off of the top of your head if there is a method to return the type of my "H5TypeId datasetNativeType"? I would have thought something like H5T.<SomeMethod> would return what the native type is.

DB

On 9/16/2011 9:04 AM, Mitchell, Scott - IS wrote:

Is it a problem that you're reading a datasetNativeType, but putting it into a byte[]? If you read curDepthDataset into a buffer of datasetNativeType, does it work?

HDF5DotNet doesn't give you much in the way of error information. So you're often left poking around for a solution when it crashes or throws an exception.

Scott

*From:*hdf-forum-bounces@hdfgroup.org [mailto:hdf-forum-bounces@hdfgroup.org] *On Behalf Of *Donald Brandon
*Sent:* Thursday, September 15, 2011 9:02 PM
*To:* HDF Users Discussion List
*Subject:* Re: [Hdf-forum] Getting an Array of values from a data set.

Anybody else have any ideas on this?

Thanks,
DB

On 9/15/2011 11:30 AM, Donald Brandon wrote:

Hey Scott:

Wouldn't that make my code look too simple? :wink:
Just kidding...

The ConvertToBytes method uses a StreamWriter and a MemoryStream to convert the array. I pulled this out and used your simpler method and it doesn't change the outcome of the code.

I have been putting in some long hours on this project and working when I am probably too tired to do so. Sometimes things just don't come to you and when you find a method that works, you don't question it much...

Thanks for your help.
DB

On 9/15/2011 11:00 AM, Mitchell, Scott - IS wrote:

DB,

Why the 'round-about way of creating a byte array? Won't this work?
byte[] buffer = newbyte[bufferSize];

What's going on inside your HdfHelper.ConvertToBytes function?

Scott

*From:*hdf-forum-bounces@hdfgroup.org <mailto:hdf-forum-bounces@hdfgroup.org> [mailto:hdf-forum-bounces@hdfgroup.org] *On Behalf Of *Donald Brandon
*Sent:* Thursday, September 15, 2011 11:45 AM
*To:* HDF Users Discussion List
*Subject:* [Hdf-forum] Getting an Array of values from a data set.

Hey all:

Trying to take a dataset of float values and build an array that can be used to generate a raster. If i have code something like this:

*// Open up the dataset.
H5DataSetId curDepthDataset = H5D.open(curHDF, curName1 + "/" + curName2 + "/" + curName3 + "/depth");
H5ObjectWithAttributes curDepthAttObj = (H5ObjectWithAttributes)curDepthDataset;

// Create a Byte[] to hold the depth data.
H5DataTypeId datasetType = H5D.getType(curDepthDataset);
H5T.H5TClass datasetClass = H5T.getClass(datasetType);
H5DataTypeId datasetNativeType = H5T.getNativeType(datasetType, H5T.Direction.ASCEND);

int bufferSize = H5T.getSize(datasetNativeType);

System.Array buffer = System.Array.CreateInstance(Type.GetType("System.Byte"), bufferSize);
Byte[] bArray = HdfHelper.ConvertToBytes(buffer);

H5D.read(curDepthDataset, datasetNativeType, new H5Array<byte>(bArray));*

Why would this give me an error like this:

*FatalExecutionEngineError was detected*

*The runtime has encountered a fatal error. The address of the error was at 0x6b344243, on thread 0x334. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.**

*I am having no trouble using this method to read the attributes out of the individual groups.

Thanks,
DB

------------------------------------------------------------------------

This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.