Exemple #1
0
def main():
    print("""\n\nSubtracting the post cure run from the cure run.\n
ATTENTION: It is assumed that cure and post-cure data are in separate files.

ATTENTION: It is assumed that these two files are in the same folder.

ATTENTION: It is assumed that these files ran through the "step_separator"-program.
Thus the first line in the files is the table header and from the second line follows the data and NOTHING else.

ATTENTION: It is assumed that tabs separate the columns.

ATTENTION: This is really just a simple subraction of data, line for line.

ATTENTION: It is assumed that cure and post-cure run are identical in time steps and temperature for each time step (but not the heat flow (or heat capacity) of course).
Meaning 1: The resulting file will contain time-steps and temperature (and heat capacity if it applies) from the cure run!
Meaning 2: If the length of the steps is not identical this program will return bogus!

ATTENTION: The time between two measurements is to be given in SECONDS. The new file
will have this time step in between the measurements. So the time in the new file will be in SECONDS! Not 
minutes as it may be the case with the original file.

ATTENTION: 
Heat Flow: It is assumed that the NORMALIZED Heat Flow is present in the raw-data.
           Not normalized heat flows will be ignored.
Heat Capacity: The heat capacity from the CURE-run will be used. Again, just the 
               NORMALIZED heat capacity will be used.
""")

    path = af.get_path()

    text = 'Name of CURE-run file (incl. extension): '
    cure_file = af.get_infile(path, text)

    text = 'Name of POST-cure-run file (incl. extension): '
    post_file = af.get_infile(path, text)

    outfile_name = af.get_user_input('outfile')

    timestep = af.get_user_input('timestep')

    cure_data = cd.Data(timestep, cure_file)
    post_data = cd.Data(timestep, post_file)

    print("Subtracting ...")
    new_data = subtracted_data(cure_data, post_data, timestep)

    # subtracted_data() has a return condition that does not do anything
    # if the data does not contain heat flow data.
    if new_data:
        order_of_variables = create_table_header(new_data)

        outfile = path + outfile_name

        print("Writing to file ...\n")
        af.write_to_file(outfile, new_data, order_of_variables)

        print(
            'A new file called < {} > was created in the same folder.'.format(
                outfile_name))
def main():
    print("""\n\nStep separation\n
This program separates all steps in DSC-files from each other and returns as 
many files as there are steps.

ATTENTION: IT IS ASSUMED THAT THE COLUMNS ARE SEPARATED WITH TABS!

ATTENTION: It is assumed that the keyword < [step] > is followed by three 
text-lines which contain the following (in this order):
line 1.: name of the step
line 2.: table header -> variables
line 3.: table header -> units

ATTENTION: This probably works just with files exported from the TA Instruments 
TRIOS software. Other vendors probably structure their files differently.
""")

    path = af.get_path()
    infile = af.get_infile(path)

    all_data, steps, table_header = extract_data(infile)

    outfiles = create_filenames(path, steps)

    for i in range(len(outfiles)):
        write_step_data_into_file(outfiles[i], table_header, all_data[i])

    move_to_new_directory(path, infile, outfiles)
    def get_values(self):
        this = 'Read values from file (F) or calculate from equation (E): '
        user_input = 'risimif'
        while not af.correct_user_input(user_input, ['f', 'e']):
            user_input = input(this)

        if user_input.lower() == 'f':
            this = '\nATTENTION: What is usually assumed regarding the structure '
            that = 'of the data in the file is assumed here, too! (First line is '
            siht = 'table header, columns separated by tabs).\n'
            print(this + that + siht)

            this = 'Full path of folder with activation energy file: '
            that = 'Name of file (incl. extension): '
            self.path = af.get_path(this + that)
            self.infile = af.get_infile(self.path)

            self._generate_values_from_file()

        elif user_input.lower() == 'e':
            # A function can be parametrized differently for different areas of
            # conversion. To be able to handle that, I need to know the number
            # of different functions.
            self.number_of_functions = af.get_user_input('number_of_functions')
            print('')
            self._generate_values_from_function()
            self._delete_duplicates()
Exemple #4
0
def main():
    print("""\n\nCalculating the total heat of reaction.\n
ATTENTION: It is assumed that the input-file ran through the "step_separator"-program. 
Thus the first line in the files is the table header and from the second line follows he data and NOTING else.

ATTENTION: It is assumed that tabs separate the columns.

ATTENTION: It is assumed that the data is post-cure run subtracted (if this applies).

ATTENTION: It is assumed that the input file is baseline corrected (meaning: steady state has a mean heat flow value of zero)

ATTENTION: The returned value will be in Joule per GRAM! 

ATTENTION: This is really just a simple addition of data.
""")

    path = af.get_path()
    infile = af.get_infile(path)

    timestep = af.get_user_input('timestep')

    data = cd.Data(timestep, infile)

    data.calculate_total_heat_of_reaction()

    print('')

    this = "The total heat of reaction is {} J/g.\n".format(data.total_heat)
    print(this)
def main():
    print("""\n\nCalculate conversion and write to file.\n
ATTENTION: It is assumed that the files ran through the "step_separator"-program.
Thus the first line in the file is the table header and from the second line follows he data and NOTING else.

ATTENTION: It is assumed that tabs separate the columns.

ATTENTION: It is assumed that the data is post-cure and baseline corrected. The program does NOT check for this!
If this is not the case the program will run anyway and return bogus!
However, it is NOT necessar that the sample reached full cure, if a value for the total heat of reaction is provided.

ATTENTION: The time between two measurements is to be given in SECONDS. The new file
will have this time step in between the measurements. So the time in the new file will be in SECONDS! Not 
minutes as it may be the case with the original file.

ATTENTION: 
Heat Flow: It is assumed that the NORMALIZED Heat Flow is present in the raw-data.
           Not normalized heat flows will be ignored.
Heat Capacity: Just the NORMALIZED heat capacity will be printed into the to the new file!
""")

    path = af.get_path()
    infile = af.get_infile(path)

    outfile_name = af.get_user_input('outfile')

    timestep = af.get_user_input('timestep')
    total_heat = af.get_user_input('total_heat', True, 'float')
    initial_conversion = af.get_user_input('initial_conversion', True, 'float')

    new_data = cd.Data(timestep, infile)

    print("Calculating the conversion ...")
    new_data.calculate_conversion(total_heat, initial_conversion)

    order_of_variables = create_table_header(new_data)

    outfile = path + outfile_name
    print("Writing to file ...\n")
    af.write_to_file(outfile, new_data, order_of_variables)

    print('A new file called < {} > was created in the same folder.'.format(
        outfile_name))
Exemple #6
0
def main():
	print("""\n\nStitching several steps together into one file\n
ATTENTION: It is assumed that the steps are separate files.

ATTENTION: It is assumed that these files are in the same folder.

ATTENTION: It is assumed that these files ran through the "step_separator"-program. Thus the first line in the files is the table header and from the second line follows he data and NOTING else.

ATTENTION: It is assumed that tabs separate the columns.

ATTENTION: This is really just a simple putting the data of one step behind the other, line for line.

ATTENTION: It is assumed that step one actually is followed by step two is followed by step three etc.

ATTENTION: It is assumed that all files have the same time step between measurements

ATTENTION: It is assumed that step one actually is followed by step two is followed by step three etc.
THIS WILL NOT BE CHECKED!

ATTENTION: The time between two measurements is to be given in SECONDS. The new file will have this time step in between the measurements. So the time in the new file will be in SECONDS! Not minutes as it may be the case with the original file.

ATTENTION: 
Heat Flow: It is assumed that the NORMALIZED Heat Flow is present in the raw-data. Not normalized heat flows will be ignored.
Heat Capacity: If heat capacity data is present just the NORMALIZED heat capacity will be used.
""")

	path = af.get_path()

	# Since I want to loop until all filenames are provided I can not 
	all_filenames = []
	i = 1
	loop = True
	while loop:
		this = 'Name of file #{} (incl. extension) -- '.format(i)
		that = 'press just ENTER to continue to next step: '
		text = this + that

		infile = af.get_infile(path, text, True)

		# af.get_infile() returns True if I allow a blank input.
		if infile == True and i > 2:
			loop = False
		elif infile == True:
			print("I won't stop asking before more than one filename is provided.")
		else:
			all_filenames.append(infile)
			i += 1


	outfile_name = 	outfile_name = af.get_user_input('outfile')


	timestep = af.get_user_input('timestep')


	all_data = []
	for infile in all_filenames:
		data = cd.Data(timestep, infile)
		all_data.append(data)

	print('')


	print("Stitching ...")
	new_data = stitched_together(all_data, timestep)

	print('')


	order_of_variables = create_table_header(new_data)

	outfile = path + outfile_name

	print("Writing to file ...\n")
	af.write_to_file(outfile, new_data, order_of_variables)

	print('A new file called < {} > was created in the same folder.'.format(outfile_name))
Exemple #7
0
def main():
    print("""\n\nCorrecting the baseline to zero\n

ATTENTION: It is assumed that the file ran through the "step_separator"-program. Thus the first line in the files is the table header and from the second line follows he data and NOTING else.

ATTENTION: It is assumed that tabs separate the columns.

ATTENTION: This is really just the simple subtraction of a value from the heat flow data.

ATTENTION: The time between two measurements is to be given in SECONDS. The new file will have this time step in between the measurements. So the time in the new file will be in SECONDS! Not minutes as it may be the case with the original file.

ATTENTION: 
Heat Flow: It is assumed that the NORMALIZED Heat Flow is present in the raw-data. Not normalized heat flows will be ignored. If no normalized heat flow data is available the program will crash
Heat Capacity: If heat capacity data is present just the NORMALIZED heat capacity will be used.
""")

    path = af.get_path()
    infile = af.get_infile(path)

    outfile_name = af.get_user_input('outfile')

    timestep = af.get_user_input('timestep')

    this = 'Steady state (normalized) heat flow '
    that = '(leave EMPTY if it shall be calculated from the data itself): '
    text = this + that
    steady_state_heat_flow = af.get_user_input(text, True, 'float')
    intervall = None

    if steady_state_heat_flow == None:
        this = 'Intervall (in SECONDS) over which the steady (normalized) heat '
        that = 'flow shall be calculated (leave EMPTY to use 5 minutes 23 '
        siht = 'seconds = 323 seconds): '
        text = this + that + siht
        intervall = af.get_user_input(text, True, 'float')

    # I always call the data "new_data", thus I keep this here, even though it
    # would not be necessary!
    new_data = cd.Data(timestep, infile)

    print('')

    print('Correcting the baseline ...')
    new_data.correct_baseline(steady_state_heat_flow, intervall)

    # If the steady state heat flow can NOT be calculated
    # data._calculate_steady_state_heat_flow() writes a note to the user and
    # returns False and subsequently data.correct_baseline sets
    # data.baseline_corrected to False and returns False.
    # Don't continue if this happens.
    if not new_data.baseline_corrected:
        return

    print('')

    order_of_variables = create_table_header(new_data)

    outfile = path + outfile_name

    print("Writing to file ...\n")
    af.write_to_file(outfile, new_data, order_of_variables)

    print('A new file called < {} > was created in the same folder.'.format(
        outfile_name))