Exemplo n.º 1
0
Code to test input and (filtered) output of a text file.
"""

# imports
import sys, os
sys.path.append(os.path.abspath('shared'))
import my_module as mymod

myplace = 'OCN506A' # *** YOU NEED TO EDIT THIS ***

# input directory
in_dir = '../' + myplace + '_data/'

# make sure the output directory exists
out_dir = '../' + myplace + '_output/'
mymod.make_dir(out_dir)

# define the input filename
in_fn = in_dir + '2017-01-0118.ctd'
# this is some Canadian CTD data, formatted in a strict but
# difficult-to-use way

# define the output filename
out_fn = out_dir + 'out_test.txt'

# open the output file for writing
outfile = open(out_fn, 'w')

# create a dict for translating direction letters to numbers
sign_dict = {'N':1,'S':-1,'E':1,'W':-1}
Exemplo n.º 2
0
# import modules
import sys, os
sys.path.append(os.path.abspath('shared'))
import my_module

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

# Specify input directory
in_dir = '../admec_input/'

# Create output directory/make sure output directory exists
out_dir = '../admec_output/'
my_module.make_dir(out_dir)

# Specify input file
in_fn = in_dir + '2017-01-0118.ctd'

# Name output files
out_fn_1 = out_dir + 'out_test_1.png'
out_fn_2 = out_dir + 'out_test_2.png'

# Method 1: use open() and for loop
with open(in_fn, 'r', errors='ignore') as f:
    get_data = False
    depth = []
    temp = []

    for line in f:
        if ('END OF HEADER' in line) and (get_data == False):