1

I have a set of files for different temperatures and have been having issues with how to store the data I need in NumPy arrays. Let's say I have a range of temperatures temperatures = [8,10,12,...] and need to store each file's first and second columns in a NumPy array (one file per temperature). The files look like these: enter image description here

The code I have so far looks like this:


import numpy as np
import sys

start_position = 84000
stop_position = 86500
step = 10

temperature = [8,10]
rootfile = 'C:root\\temperature_MnTe2__'
length_data = np.arange(250)
positions = np.zeros(shape=len(temperature))
# print(positions)
inphase = np.zeros(len(temperature))
for t in temperature:
    # positions[t],inphase[t] = np.genfromtxt(rootfile + str(t) + '.0K.tsv', delimiter='     ', skip_header=23, unpack='True')
    data = np.genfromtxt(rootfile + str(t) + '.0K.tsv', delimiter='      ', skip_header=23, unpack='True')
    # print(data[0])
    # sys.exit()
    for column in data:
        print(column)
        for l in length_data:
            positions[l] = column[0]
            print(positions)

The total number of rows for each column is 250. Do you have any ideas on how to create the arrays for each temperature so that at the end, I can more easily access the 1st and 2nd columns to plot them for each temperature?

I'd like to know also how to save all values of the first column in an array called positions and that when I go over the second temperature, it stores it in the same array in a different column, for instance. Currently, my positions array contains only the first value of the column of one temperature.

Thank you so much in advance,

valit
  • 41
  • 4

0 Answers0