Skip to main content

Flow Design for Script to Use HDF5 Files instead of O

Create the Python Script on https://github.com/gqc/gqc-utility-python project. I am going to name the script. hdf_to_sqlserver.py

Navigating the HDF5 File is going to come from the script insert_flow_history from the Orsanco Backend project.

Once it is in a dataframe called flow_dataset and velocity_dataset. At this point there is no time in the data set. Instead there is a datetime_dataset. I am going to create a 2nd datetime Dataset and add 9 hrs to every value. I will repeat this process until I have 4 data sets in total each one will begin 9 hrs after the previous one.

I will turn it into Unix Timestamp first so I will be adding a constant.

  • So 1st original dataset will come from HDF5 file.
  • 2nd dataset is 1st + 9 hrs.
  • 3rd dataset is 2nd + 9 hrs.
  • 4th dataset is 3rd + 9 hrs.

Concatenate the time dataframes into 1 df.

Check the shape of the time dataframe.

use pd Concatenate to duplicate the flows and velocities dataframe 4 times.

This will make the Velocities dataframe have 0 values every 9 rows

add the times into the duplicated dataframe.

Check the shape again.

Use Pandas Melt to change piviot the dataframe. Combine the Flow and velocity dataframe.

Insert the new flow data into the SQLServer.