Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I want to see ice mover, but I cna't #167

Open
tottorikenn opened this issue Dec 3, 2024 · 0 comments
Open

I want to see ice mover, but I cna't #167

tottorikenn opened this issue Dec 3, 2024 · 0 comments

Comments

@tottorikenn
Copy link

Dear All.
I want to see only ice mover now.

https://github.com/user-attachments/assets/e89b0689-10b0-4f08-a6f9-f0c381c31eea
siconc shows ice concentration.
there is much ice at spill position. Higher than 80 I think.
start_x(lon)=30.960
start_y(lat)=77.928
This vector plot shows ice vector.
https://github.com/user-attachments/assets/f83081ff-d119-4076-bced-9ad24623156c

So I think, I could watch a oil move by ice mover, if i run a python program corretly. But I can't see oil moving.
https://github.com/user-attachments/assets/17d0a1c8-4792-46ae-85bc-4d4f13925d19
This is a simulation result. I can't see any mover at all.
I ran this code to only see ice mover.

start_x=30.960
start_y=77.928
x_min=28
x_max=33
y_min=76
y_max=79

import gnome.scripting as gs
import os

mapfile = gs.get_datafile('ne_110m_coastline.bna')
mymap = gs.MapFromBNA(mapfile) # no refloat
#mymap = gs.MapFromBNA(mapfile, refloat_halflife=-1) # no refloat

start_time = gs.asdatetime("2009-05-14T00:00")
oil = gs.GnomeOil(filename="troll-blend_EX00051.json")
model = gs.Model(start_time=start_time,
duration=gs.days(8),
time_step=60 * 15, # 15 minutes in seconds
)
model.map = mymap
release_time = gs.asdatetime("2009-05-15T08:00")
spill = gs.surface_point_line_spill(num_elements=1000,
start_position=(start_x, start_y),
release_time=release_time,
end_position=(start_x, start_y),
end_release_time= release_time + gs.days(1),
amount=5000,
#substance=oil,
windage_range=(0.01, 0.04),
windage_persist=-1,
name='My spill')
model.spills += spill

... add movers/weatherers

#add wind
w_mover = gs.GridWind.from_netCDF('data_stream-oper.nc',uncertain_speed_scale=2.0, uncertain_angle_scale=0.4,wind_scale=1)
wind_mover= gs.WindMover(w_mover)
#model.movers += wind_mover

#add current
fn = 'interpolated_data_my_pc_4_renamed.nc'
current_mover = gs.CurrentMover.from_netCDF(filename=fn)
#model.movers += current_mover

#add ice current
ice_aware_curr = gs.IceAwareCurrent.from_netCDF(filename=fn)
ice_current_mover = gs.CurrentMover(ice_aware_curr)

#add ice wind
wind ='data_stream-oper.nc'
ice_aware_wind = gs.IceAwareWind.from_netCDF(filename=wind,
ice_concentration=ice_aware_curr.ice_concentration,
ice_velocity=ice_aware_curr.ice_velocity
)
ice_wind_mover = gs.WindMover(ice_aware_wind)

renderer = gs.Renderer(output_dir='./output_fex2009_ice_2/',
output_timestep=gs.hours(2),
# bounding box for the output images
viewport=((x_min, y_min), (x_min, y_max),
(x_max, y_max), (x_max, y_min)),
formats=['gif']
)
model.outputters += renderer

shape =gs.ShapeOutput('pygnome_fex2009_ice_2', zip_output=True, include_certain_boundary=False,
certain_boundary_separate_by_spill=True, certain_boundary_hull_ratio=0.5,
certain_boundary_hull_allow_holes=False, include_uncertain_boundary=True,
uncertain_boundary_separate_by_spill=True, uncertain_boundary_hull_ratio=0.5,
uncertain_boundary_hull_allow_holes=False, surface_conc='kde')
model.outputters += shape
'''
x_min=28
x_max=33
y_min=76
y_max=79
'''
rend = gs.Renderer(map_filename=mapfile,output_dir='pygnome_fex2009_ice_2',image_size=(800, 800),# (1280,1024)
projection=None,
viewport=((28, 76),(33,79)), # (lon,lat): lowerleft,upperright
draw_back_to_fore=True,draw_map_bounds=True,draw_spillable_area=True,
formats=['png'],draw_ontop='forecast',
output_timestep=gs.hours(1),
output_zero_step=False,output_last_step=True,output_start_time=None,surface_conc='kde',timestamp_attrib={})
model.outputters += rend

'''
d1 = Dataset('winds_hourly.nc')
lon_var1 = d1['lon'][:]
lat_var1 = d1['lat'][:]
lon1, lat1 = np.meshgrid(lon_var1, lat_var1)
g1 = Grid_S(node_lon = lon1, node_lat = lat1)
g1.build_celltree()
objeto1 = GridCurrent.from_netCDF(dataset=d1,grid_topology={'node_lon':'lon','node_lat':'lat'},varnames=['air_u', 'air_v'], units='m/s',grid=g1)
rend.add_vec_prop(objeto1, on=True,color='LE', mask_color='uncert_LE',size=5, width=3, scale=1000)
'''

images_dir = 'nc_pygnome_fex2009_wind_2'
#gs.make_images_dir(images_dir)
netcdf_file = os.path.join(images_dir, 'pygnome_fex2009__ice_2.nc')
gs.remove_netcdf(netcdf_file)
nc_outputter = gs.NetCDFOutput(netcdf_file,
which_data='all',
output_timestep=gs.hours(1),
)
model.outputters += nc_outputter

model.full_run()

Best regard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant