# Run Simulation From Script

If the user requires more control over the simulation, he/she can make a custom python script, just like for any other OpenDrift simulation.

Start by importing all required dependencies.

                        import numpy as np
                        from opendrift.readers import reader_netCDF_CF_generic
                        from opendrift.readers import reader_global_landmask
                        from datetime import datetime, timedelta
                        from netCDF4 import Dataset
                        from carbondrift.models.areadecay import carbondrift

Setup readers, configures and initial conditions.

                        #Import readers
                        btm = reader_netCDF_CF_generic.Reader("./supplementary_data/etopo2_remaped1deg.nc",
                                                                standard_name_mapping={"topo":"depth"})
                        tmp = reader_netCDF_CF_generic.Reader("./supplementary_data/tmp_luo_remaped1deg.nc")
                        lm = reader_global_landmask.Reader()

                        #Increase buffer, since vertical speeds are large!
                        tmp.verticalbuffer = 100
                        tmp.always_valid = True

                        #Define start time
                        time = datetime(year=1993, month = 1, day = 1)

                        #Set up configures
                        config = {'drift:advection_scheme':"runge-kutta",
                                    'general:use_auto_landmask': False, 'seed:ocean_only':False}

                        #Initial mass and vertical velocity
                        mass =  np.ones(2)
                        w0 = -0.009259

                        outfile = "outNetCDFFilePath"

Initialize and configure CarbonDrift object.

                        o = carbondrift.CarbonDrift(loglevel = 0, initial_velocity = w0,
                                                    m0 = mass, decay_type = "linear")

                        #Deactivate horizontal advection and fragmentation
                        o.deactivate_horizontal_advection()
                        o.deactivate_fragmentation()

                        #Set readers and configures
                        o.add_reader([btm, tmp, lm])
                        for key, value in config.items():
                            o.set_config(key, value)

Seed and run simulation.

                        o.seed_elements(lon = [146, -45], lat = [58, 30],
                                        time = time, mass = mass, z = -50)

                        o.run(outfile=outfile, steps = 5, time_step=timedelta(minutes = 30),
                                time_step_output=timedelta(hours = 2))