import sys

# First argument should be k
# Second argument should be 1 if on balena, 0 otherwise
# Third argument should be which 'set' of beta you want to run
# 0 --> beta = 0.0
# 1 --> beta = [-0.1,-0.2]
# 2 --> beta = [-0.3,-0.4,-0.5]
# 3 --> beta = [-0.6,-0.7,-0.8,-0.9,-1.0]
# Fourth argument should be number of repeats

on_balena = bool(int(sys.argv[2]))

if on_balena:
    from firedrake_complex_hacks.balena_hacks import fix_mesh_generation_time
    fix_mesh_generation_time()

beta_set = int(sys.argv[3])

k_list = [float(sys.argv[1])]

print(k_list, beta_set)

h_list = [(1.0, -1.5)]

p_list = [1]

num_repeats = int(sys.argv[4])

num_pieces = 10
j_scaling
dim
on_balena
h_coarse_spec[0]
h_coarse_spec[1]
nearby_preconditioning
nearby_preconditioning_proportion

All subsequent arguments should be strings, giving the names of the qois to consider
"""
quants = make_quants(sys.argv[1:])

if quants['on_balena']:
    print('loading module')
    from firedrake_complex_hacks import balena_hacks
    balena_hacks.fix_mesh_generation_time()

# Strategy for saving the files:
# 1. Create a uniquely named folder, with name of the form: properties, hash, date/time
#2. Within this folder, save k, samples, and n_coeffs (and anything else that comes along later) in generically-named files

# Analysis script will then:
# 1. Take in the parameters we want to use for analysis (e.g., values of k, j_scaling, etc.)
#2. Find the folders corresponding to all the parameters we want (throw a question if there's more than one exact match - default is to take the newest
# Do the analysis required (probably the same plots we have at the moment, just including everything in the title)

if fd.COMM_WORLD.rank == 0:
    # Add all values to start of folder name
    quants_tmp = deepcopy(quants)

    quants_tmp['nbpc_prop'] = np.round(