Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6763707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:30:30+00:00 2026-05-26T14:30:30+00:00

I have a NetCDF file, which contains data representing total precipitation across the globe

  • 0

I have a NetCDF file, which contains data representing total precipitation across the globe over several months (so it’s stored in a three dimensional array). I first ensured that the data was sensible, and the way it was formed, both in XConv and ncdump. All looks sensible – values vary from very small (~10^-10 – this makes sense, as this is model data, and effectively represents zero) to about 5×10^-3.

The problems start when I try to handle this data in IDL or MatLab. The arrays generated in these programs are full of huge negative numbers such as -4×10^4, with occasional huge positive numbers, such as 5000. Strangely, looking at a plot of the data in MatLab with respect to latitude and longitude (at a specific time), the pattern of rainfall looks sensible, but the values are just completely wrong.

In IDL, I’m reading the file in to write it to a text file so it can be handled by some software that takes very basic text files. Here’s the code I’m using:

PRO nao_heaps

address = '/Users/levyadmin/Downloads/'
file_base = 'output'
ncid = ncdf_open(address + file_base + '.nc')

MONTHS=['january','february','march','april','may','june','july','august','september','october','november','december']

varid_field = ncdf_varid(ncid, "tp")
varid_lon = ncdf_varid(ncid, "longitude")
varid_lat = ncdf_varid(ncid, "latitude")
varid_time = ncdf_varid(ncid, "time")

ncdf_varget,ncid, varid_field, total_precip
ncdf_varget,ncid, varid_lat, lats
ncdf_varget,ncid, varid_lon, lons
ncdf_varget,ncid, varid_time, time

ncdf_close,ncid

lats = reform(lats)
lons = reform(lons)
time = reform(time)
total_precip = reform(total_precip)
total_precip = total_precip*1000. ;put in mm

noLats=(size(lats))(1)
noLons=(size(lons))(1)
noMonths=(size(time))(1)

; the data may not be an integer number of years (otherwise we could make this next loop cleaner)
av_precip=fltarr(noLons,noLats,12)
for month=0, 11 do begin
  year = 0
  while ( (year*12) + month lt noMonths ) do begin
    av_precip(*,*,month) = av_precip(*,*,month) + total_precip(*,*, (year*12)+month )
    year++
  endwhile
  av_precip(*,*,month) = av_precip(*,*,month)/year
endfor

fname = address + file_base + '.dat'
OPENW,1,fname
PRINTF,1,'longitude'
PRINTF,1,lons

PRINTF,1,'latitude'
PRINTF,1,lats

for month=0,11 do begin
  PRINTF,1,MONTHS(month)
  PRINTF,1,av_precip(*,*,month)
endfor


CLOSE,1

END

Anyone have any ideas why I’m getting such strange values in MatLab and IDL?!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:30:31+00:00Added an answer on May 26, 2026 at 2:30 pm

    AH! Found the answer. NetCDF files use an offset, and a scale factor for the data to keep the size of the file to a minimum. To get the correct values, I simply need to:

    total_precip = offset + (scale_factor * total_precip) ;put into correct range
    

    At present I’m getting the scale factor and offset from ncdump, and hard coding them into my IDL program, but does anyone know how I can get them dynamically in my IDL code..?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a variety of time-series data stored on a more-or-less georeferenced grid, e.g.
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Anyone out there have enough experience w/ NetCDF and HDF5 to give some pluses
Have created a ATL COM project through which I am inserting Menu Items to
Have anyone used Redmine Documentor which lets you convert PHP to HTML to Redmine
have the following text file: <div> <asp:HyperLinkField HeaderText=Hello World of Regular Expression /> </div>
Have a bunch of classes which I need to do serialize and deserialize from/to
I have an application I'm building that's using the NetCDF C++ library, and NetCDF
Have a stored procedure that produces a number--let's say 50, that is rendered as
Have just started using Google Chrome , and noticed in parts of our site,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.