no bitcount using roms_write_era5_NCARds633_frcfile.m

Discussion about analysis, visualization, and collaboration tools and techniques

Moderators: arango, robertson

Post Reply
Message
Author
Dan_chan
Posts: 38
Joined: Wed Apr 17, 2019 2:37 am
Location: IAP, UCAS

no bitcount using roms_write_era5_NCARds633_frcfile.m

#1 Unread post by Dan_chan »

Hi,
I am using Matlab tool shared by Wilkin to write forcing file.

First, I got E value using roms_get_era5_NCARds633_bulkflux.m. I chose the real box as 99E-140E 0-26N, and set bbox as [-261 -220 0 26]. This function worked well and E value generated.

Then, I run roms_write_era5_NCARds633_frcfile.m directly, but the error said "Unrecognized function or variable 'bitcount'." I checked nc_write.m and it had not bitcount before line 216. And I don't know bitcount in this location is a function or variable and where is it?

Code: Select all

>> load('E.mat')
>> roms_write_era5_NCARds633_frcfile

Creating ROMS NetCDF forcing file: frc_watl_ERA5_bulkflux_201001.nc

Unrecognized function or variable 'bitcount'.

Error in nc_write>nc_write_matlab (line 216)
CheckSum = bitcount(f(ind));

Error in nc_write (line 68)
    status = nc_write_matlab(ncfile, Vname, f, Tindex, Info);

Error in roms_write_era5_NCARds633_frcfile (line 151)
nc_write(Outfile,'spherical',int32(spherical));
I also checked Matlab functions. There are bitand, bitcmp, bitconcat, bitget, bitor, bitrevorder, bitset, bitshift, bitsll, bitsra, bitsrl, bitxor, but no bitcount. My Matlab version is R2021b for Mac.

Many thanks in advance.

Dan

Dan_chan
Posts: 38
Joined: Wed Apr 17, 2019 2:37 am
Location: IAP, UCAS

Re: no bitcount using roms_write_era5_NCARds633_frcfile.m

#2 Unread post by Dan_chan »

Sorry,

Maybe I missed bitcount. I download bitcount function from matlab web. https://ww2.mathworks.cn/matlabcentral/ ... bitcount_2.

Now, roms_write_era5_NCARds633_frcfile.m is ok.

Thanks to all.

Dan_chan
Posts: 38
Joined: Wed Apr 17, 2019 2:37 am
Location: IAP, UCAS

Re: no bitcount using roms_write_era5_NCARds633_frcfile.m

#3 Unread post by Dan_chan »

Hi,

I still have a problem on bbox. I am used to -180 to 180 or 0 to 360 when read longitude. But, the output is -360 to 0 when units shows 'degree_east'. I want to make sure that this is correct or not?

I had set bbox as [99 140 0 26] before, but error showed like:

Code: Select all

Processing variable mean sea-level pressure
Error using ncread
Expected start to be nonempty.

Error in internal.matlab.imagesci.nc/read (line 596)
                    validateattributes(start,{'numeric'},...

Error in ncread (line 66)
vardata = ncObj.read(varName, varargin{:});

Error in roms_get_era5_NCARds633_bulkflux (line 292)
  lon = ncread(url,'longitude',Is,Ilen)-360;

Error in test1_forcing (line 11)
E = roms_get_era5_NCARds633_bulkflux(yyyy,mm,bbox,user);
 
so I had to change bbox = [-261 -220 0 26] that roms_get_era5_NCARds633_bulkflux function worked.

I am a little confused.

Thanks for any help.

Dan

User avatar
arango
Site Admin
Posts: 1361
Joined: Wed Feb 26, 2003 4:41 pm
Location: DMCS, Rutgers University
Contact:

Re: no bitcount using roms_write_era5_NCARds633_frcfile.m

#4 Unread post by arango »

I added the useful bitcount.m and other helpful Matlab scripts to the Matlab repository. Please update.

Dan_chan
Posts: 38
Joined: Wed Apr 17, 2019 2:37 am
Location: IAP, UCAS

Re: no bitcount using roms_write_era5_NCARds633_frcfile.m

#5 Unread post by Dan_chan »

Hi Arango,

Thank you for kind help.

Dan

Dan_chan
Posts: 38
Joined: Wed Apr 17, 2019 2:37 am
Location: IAP, UCAS

Re: no bitcount using roms_write_era5_NCARds633_frcfile.m

#6 Unread post by Dan_chan »

(to answer #3)

Refer to forum viewtopic.php?p=22253#p22253 (#13), I try to modify roms_get_era5_NCARds633_bulkflux in around line 282 and line 292.

original version:

Code: Select all

lon = ncread(url,'longitude')-360;            % read global lon, this is to change (180,360] to [-180,0] which is work for Western Hemisphere
lon = ncread(url,'longitude',Is,Ilen)-360;    % read local lon (which will be written in ncfile)
modified version:

Code: Select all

lon = ncread(url,'longitude')
lon = ncread(url,'longitude',Is,Ilen);
Then, longitude of input bbox and output ncfile could keep 0-360 easier in the eastern hemisphere.

Last, thanks for these perfect Matlab functions in roms.

User avatar
arango
Site Admin
Posts: 1361
Joined: Wed Feb 26, 2003 4:41 pm
Location: DMCS, Rutgers University
Contact:

Re: no bitcount using roms_write_era5_NCARds633_frcfile.m

#7 Unread post by arango »

By the way, there are a couple of obscure native Matlab functions in its maputils that can be used to reset the longitude range to [0 360] or [-180 180]:

Code: Select all

>  lon = wrapTo360(lon);
>  lon = wrapTo180(lon);
These functions are helpful when setting ROMS grids and datasets in Matlab. I bet that they are similar functions in other processing software.

Dan_chan
Posts: 38
Joined: Wed Apr 17, 2019 2:37 am
Location: IAP, UCAS

Re: no bitcount using roms_write_era5_NCARds633_frcfile.m

#8 Unread post by Dan_chan »

Thank you arango,

They are useful to change my lon of past downloded file.

User avatar
wilkin
Posts: 918
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: no bitcount using roms_write_era5_NCARds633_frcfile.m

#9 Unread post by wilkin »

Do you have a current version of this function from https://github.com/johnwilkin/roms_wilkin ?

I updated it 4 months ago in response to a similar post from another user, and I just tested that ...

Code: Select all

>> E = roms_get_era5_NCARds633_bulkflux(2020,1,[99 140 0 26])
works just fine with the present version.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

Dan_chan
Posts: 38
Joined: Wed Apr 17, 2019 2:37 am
Location: IAP, UCAS

Re: no bitcount using roms_write_era5_NCARds633_frcfile.m

#10 Unread post by Dan_chan »

Dear Wilkin,

Is there any difference between svn and github? I used svn to download and svn update in current dir. But it keeps -360.

If so, I might to download from github.

Thank you

User avatar
wilkin
Posts: 918
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: no bitcount using roms_write_era5_NCARds633_frcfile.m

#11 Unread post by wilkin »

You are correct that the svn version is out of date. I'll try to get that updated soon, but the latest version will always be at GitHub for the foreseeable future.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

Dan_chan
Posts: 38
Joined: Wed Apr 17, 2019 2:37 am
Location: IAP, UCAS

Re: no bitcount using roms_write_era5_NCARds633_frcfile.m

#12 Unread post by Dan_chan »

Thank you wilkin, I will git it for keeping latest version.

User avatar
wilkin
Posts: 918
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: no bitcount using roms_write_era5_NCARds633_frcfile.m

#13 Unread post by wilkin »

I have updated the svn repository, but at some time in the medium term future we will shut that down and keep everything just in GitHub.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

Post Reply