import metal_library as mlib

print(mlib.supported_components)

reader = mlib.Reader(component_name='TransmonCross')
print(reader)

reader.component_types

reader.get_characteristic_info(component_type="QubitOnly");

reader.get_characteristic_info(component_type="QubitCavity");

reader.get_characteristic_info(component_type="QubitDriveline");

reader = mlib.Reader(component_name='TransmonCross')
reader.read_library(component_type='QubitOnly')

#### REMINDER: don't skip the previous cell! 
selector = mlib.Selector(reader)
print(selector)

# You can find the supported metrics here...
selector.__supported_metrics__

indexes, chars, best_geoms = selector.find_closest(target_params={"Qubit_Frequency_GHz": 5,
                                                                  "Qubit_Anharmonicity_MHz": 200},
                                                   num_top=3,
                                                   metric="Euclidian",
                                                   display=True)

%load_ext autoreload
%autoreload 2

# Qiskit Metal imports
import qiskit_metal as metal
from qiskit_metal import designs, draw
from qiskit_metal import MetalGUI, Dict

design = designs.DesignPlanar()

gui = MetalGUI(design)

reader.component_name

from qiskit_metal.qlibrary.qubits.transmon_cross import TransmonCross

# Parsing the best geometries 
best_options        = best_geoms[0]
second_best_options = best_geoms[1]
third_best_options  = best_geoms[2]
# and so on.. so on...

TransmonCross(design, "transmon", options=best_options)

gui.rebuild()
gui.zoom_on_components(['transmon'])
gui.screenshot()

reader = mlib.Reader(component_name='TransmonCross')
reader.read_library(component_type='QubitCavity') # Note, we've change it from "QubitOnly" -> "QubitCavity"

selector = mlib.Selector(reader)

indexes, chars, best_geoms = selector.find_closest(target_params={"Qubit_Frequency_GHz": 5,
                                                                  "Qubit_Anharmonicity_MHz": 200,
                                                                  "Cavity_Frequency_GHz": 7,
                                                                  "Coupling_Strength_MHz": 70,
                                                                  "Cavity_Wavelength": "half", # acceptable inputs ["half", "quarter"], refers to wavelength of resonator
                                                                  "Feedline_Coupling": 'capacitive' #acceptable inputs ["capacitive", "inductive"], refers to 
                                                                  } 
                                                   num_top=3,
                                                   metric="Euclidian",
                                                   display=True)

%load_ext autoreload
%autoreload 2

# Qiskit Metal imports
import qiskit_metal as metal
from qiskit_metal import designs, draw
from qiskit_metal import MetalGUI, Dict

design = designs.DesignPlanar()

gui = MetalGUI(design)

from metal_library.components import QubitCavity

# Parsing the best geometries 
best_options        = best_geoms[0]
second_best_options = best_geoms[1]
# and so on...

design = QubitCavity(design, options=best_options)


gui.rebuild()
gui.autoscale()
gui.screenshot()