Tilgang på data

NetCDF-filer med data

Hindcast-data som NetCDF-filer finnes her: https://thredds.met.no/thredds/catalog/fjordos/fjordos2_hindcast/v6/exp1/catalog.html

Eksempler på hvordan data’en kan leses

Eksempel 1: Hente og plotte dybdematrisen (Matlab)
        FOfil = 'https://thredds.met.no/thredds/dodsC/fjordos/fjordos2_hindcast/v6/exp1/ocean_his_0001.nc4';
        lon_rho = ncread(FOfil,'lon_rho');
        lat_rho = ncread(FOfil,'lat_rho');
        h = ncread(FOfil,'h');
        mask = ncread(FOfil,'mask_rho');
        h(~mask) = NaN;

        ha = pcolor(lon_rho,lat_rho,h);
        set(ha,'EdgeColor','none')
        caxis([0,200]);
        ylabel(colorbar,'Depth [m]','fontsize', 12, 'fontweight', 'bold','color','k')
        xfac = cos(mean(lat_rho(:))*pi/180);
        set(gca, 'DataAspectRatio', [1 xfac 1] );
        xlabel('Lengdegrad (^oE)','Fontsize',12,'FontWeight','bold')
        ylabel('Breddegrad (^oN)','Fontsize',12,'FontWeight','bold')
        axis tight
Eksempel 2: Hente og plotte vannstand ved Oscarsborg (Matlab)
        FOfil = 'https://thredds.met.no/thredds/dodsC/fjordos/fjordos2_hindcast/v6/exp1/ocean_his_0001.nc4';
        ocean_time = ncread(FOfil,'ocean_time');
        tid = ocean_time/3600/24 + datenum([1970,01,01,00,00,00]);
        zeta = squeeze(ncread(FOfil,'zeta',[201,583,1],[1,1,Inf]));
        plot(tid,zeta,'r')
        datetick('x')
        ylabel('Vannstand [cm]','FontWeight','bold','FontSize',12)

Eksempel 3: Hente og plotte dybdematrisen (Python)
        from netCDF4 import Dataset
        import numpy as np
        import cmocean 
        import matplotlib.pyplot as plt
        from mpl_toolkits.basemap import Basemap

        # Henter data fra thredds
        url = 'http://thredds.met.no/thredds/dodsC/fjordos/operational_archive/daily/ocean_his.nc_2018021400'
        nc = Dataset(url)

        # Plukker ut dyp-data
        h = nc.variables['h'][:,:]
        mask_rho = nc.variables['mask_rho'][:,:]
        lon = nc.variables['lon_rho'][:,:]
        lat = nc.variables['lat_rho'][:,:]
        h=np.ma.masked_where(mask_rho < 0.5,h)

        # Plotter
        fig = plt.figure(figsize=(5,5))
        m = Basemap(projection='stere',lon_0=10.5,lat_0=59.5,lat_ts=60,
                      llcrnrlon=10.00,urcrnrlon=11.2,
                      llcrnrlat=58.97,urcrnrlat=59.93,
                      rsphere=6.371e+06, resolution='i')

        # draw parallels.
        parallels = np.arange(0.,90.,0.1)
        m.drawparallels(parallels,labels=[1,0,0,0],fontsize=10)
        # draw meridians
        meridians = np.arange(0.,360.,0.2)
        m.drawmeridians(meridians,labels=[0,0,0,1],fontsize=10)
        # depth
        x,y = m(lon,lat)
        cmes = m.pcolormesh(x,y,h,cmap=cmocean.cm.deep,vmin=0,vmax=400)
        cbar = m.colorbar(cmes,location='right',pad="10%")
        cbar.set_label('Depth [m]')
        m.plot

        plt.show()