Re: file fatal error handling

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Fri May 06 2011 - 14:33:10 MDT

The "fatal" message below pertains to the addfile function
and not the script as a whole. John is correct that you can
test to see if 'f' is missing and make a decision. Still, if
you are processing many files, you could get many printed
'fatal' errors. You could avoid these using the following

http://www.ncl.ucar.edu/Document/Functions/Built-in/NhlGetErrorObjectId.shtml

Let's say you have something like

       fils = (/ files_to_be_processed /)
or
       fils = systemfunc("ls ...")

       nfils = dimsizes(fils)

       err = NhlGetErrorObjectId()
       setvalues err
          "errPrint" : "False" ; turn off all error msg printing
       end setvalues

       do nf=0,nfils-1
          f = addfile(....)
          if (ismissing(f)) then
              continue ; problem w file; jump to next iteration
          end if
          ; process file
       end do

       setvalues err
          "errPrint" : "True" ; return to default mode
       end setvalues

Note that this type of approach could be used to suppress
(say) Warning messages

       errMsg = NhlGetErrorObjectId()
       setvalues errMsg
           "errLevel" : "Fatal" ; only print Fatal messages
       end setvalues

then later

       setvalues errMsg
           "errLevel" : "Warning" ; return to default
       end setvalues

On 5/6/11 6:18 AM, John Kerfoot wrote:
>
>
> On Fri, May 6, 2011 at 8:02 AM, <ncl-talk-request@ucar.edu
> <mailto:ncl-talk-request@ucar.edu>> wrote:
>
> Send ncl-talk mailing list submissions to
> ncl-talk@ucar.edu <mailto:ncl-talk@ucar.edu>
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> or, via email, send a message with subject or body 'help' to
> ncl-talk-request@ucar.edu <mailto:ncl-talk-request@ucar.edu>
>
> You can reach the person managing the list at
> ncl-talk-owner@ucar.edu <mailto:ncl-talk-owner@ucar.edu>
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of ncl-talk digest..."
>
>
> Today's Topics:
>
> 1. Re: About Search Engine (Chad Herman)
> 2. file fatal error handling (Vladyslav Lyubartsev)
> 3. About Vector plot (Cheung)
> 4. Plug-In for the NetBeans IDE (Robert Schuster)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 05 May 2011 14:28:45 -0400
> From: Chad Herman <chad.herman.us <http://chad.herman.us>@gmail.com
> <http://gmail.com>>
> Subject: Re: About Search Engine
> To: ncl-talk@ucar.edu <mailto:ncl-talk@ucar.edu>
> Message-ID: <4DC2EC5D.8030003@gmail.com
> <mailto:4DC2EC5D.8030003@gmail.com>>
> Content-Type: text/plain; charset=windows-1252; format=flowed
>
> I've noticed that if you do a search from the little search box in the
> upper right hand corner, everything goes fine. But if you refine that
> search or even repeat the search in the search results page, you get an
> error:
>
> 404. That?s an error.
> The requested URL
> /custom?hl=en&site=u%2Fncar&output=u%2Fncar&ie=ISO-8859-1&q=daily+to+monthly+average&btnG=Search
> was not found on this server. That?s all we know.
>
> Try it out for yourself, go to:
> http://www.googlesyndicatedsearch.com/u/ncar?sa=Search&q=daily+to+monthly+average
> <http://www.googlesyndicatedsearch.com/u/ncar?sa=Search&q=daily+to+monthly+average>
>
> Now click search. Also, as a previous author noted, so many non-NCL
> related sites show up. I found that short of using google to search
> site:ncl.ucar.edu <http://ncl.ucar.edu>, just typing "NCL" will
> filter out a lot of the noise.
>
> Chad
>
>
> ------------------------------
>
> Message: 2
> Date: Fri, 6 May 2011 10:02:01 +0200
> From: "Vladyslav Lyubartsev" <vladyslav.lyubartsev@cmcc.it
> <mailto:vladyslav.lyubartsev@cmcc.it>>
> Subject: file fatal error handling
> To: <ncl-talk@ucar.edu <mailto:ncl-talk@ucar.edu>>
> Message-ID: <001501cc0bc3$e1a50b80$a4ef2280$@lyubartsev@cmcc.it
> <mailto:lyubartsev@cmcc.it>>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi,
> I have to process a huge archive of netCDF file, some of them are
> corrupted,
> and I cannot find any NCL workaround to avoid this situation:
>
> f=addfile("test.nc <http://test.nc>","r")
> fatal:NetCDF: Unknown file format
> fatal:Could not open (test.nc <http://test.nc>)
>
> As for me in this case the best way would be to raise just warning, set
> variable "f" to missing value, and raise fatal error later, when it
> will be
> really fatal.
> Anyway, which way could you recommend to avoid the script crashing?
>
> Best regards,
> Slava
>
> Hi Slava,
>
> If the file doesn't exist or can't be read, NCL (at least in version
> 6.0) sets the value of f to the missing value. So you could check this
> with something like:
>
> f=addfile("test.nc <http://test.nc/>","r")
> fatal:NetCDF: Unknown file format
> fatal:Could not open (test.nc <http://test.nc/>)
>
> if (ismissing(f)) then
> print("Invalid file!")
> exit
> end if
>
> .....
>
>
> This would cause the script to exit gracefully.
>
> John
>
>
>
>
> ------------------------------
>
> Message: 3
> Date: Fri, 6 May 2011 17:39:15 +0800 (CST)
> From: Cheung <zuibeidemei@126.com <mailto:zuibeidemei@126.com>>
> Subject: About Vector plot
> To: ncl-talk@ucar.edu <mailto:ncl-talk@ucar.edu>
> Message-ID: <1149a99.119bb.12fc4ace1c2.Coremail.zuibeidemei@126.com
> <mailto:1149a99.119bb.12fc4ace1c2.Coremail.zuibeidemei@126.com>>
> Content-Type: text/plain; charset="gbk"
>
> Dear all:
>
>
> I have a 2d data plotted respectively by gsn_vector and
> gsn_csm_vector, but the results are different. (attached files)
> And the 'gsn_vector' one is reasonable cause I also use other
> software to display the data. So can anyone tell me why, I really
> need to use gsn_csm_vector because of some functions. My data is
> u(lev, lon) and w(lev,lon) , 22*25. no special resources set.
>
>
> Regards!
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20110506/418c49b1/attachment.html
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: gsn_csm_vector.png
> Type: image/png
> Size: 14122 bytes
> Desc: not available
> Url :
> http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20110506/418c49b1/attachment.png
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: gsn_vector.png
> Type: image/png
> Size: 14763 bytes
> Desc: not available
> Url :
> http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20110506/418c49b1/attachment-0001.png
>
> ------------------------------
>
> Message: 4
> Date: Fri, 6 May 2011 14:01:51 +0200
> From: Robert Schuster <rxschuster@googlemail.com
> <mailto:rxschuster@googlemail.com>>
> Subject: Plug-In for the NetBeans IDE
> To: ncl-talk <ncl-talk@ucar.edu <mailto:ncl-talk@ucar.edu>>
> Message-ID: <3975B941-A8E3-4B7A-B350-245B93D8B440@googlemail.com
> <mailto:3975B941-A8E3-4B7A-B350-245B93D8B440@googlemail.com>>
> Content-Type: text/plain; charset="us-ascii"
>
> Dear NCL users,
>
> I have started to work on a Plug-In for the Netbeans IDE to support
> NCL files. Until now it has the following features:
>
> Syntax Highlight:
> Highlight of keywords, procedures and function names, attributes,
> coordinates, strings, comments, etc..
>
> Syntax Check:
> Basic syntax checks are performed. Most parts of the NCL Syntax are
> recognized and errors are marked with a red wave under the error
> position. Some potential errors are also checked. For example if a
> function has no return value.
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: PastedGraphic-2.tiff
> Type: image/tiff
> Size: 89246 bytes
> Desc: not available
> Url :
> http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20110506/24306d2f/attachment.tiff
> -------------- next part --------------
>
> In some cases, the syntax check is too stringent. This is an example
> from gsn_csm.ncl, there is obviously a right brace to much, but NCL
> don't cares about errors like that.
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: PastedGraphic-4.tiff
> Type: image/tiff
> Size: 23744 bytes
> Desc: not available
> Url :
> http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20110506/24306d2f/attachment-0001.tiff
> -------------- next part --------------
>
> There are maybe also syntax error that are not detected, or detected
> errors that are definitively no errors.
>
> Code Completion:
> The plugin knows the names of all NCL procedures or functions. You
> just need to start typing the first letters, then press CTRL-SPACE,
> then you will get a list with all procedures or functions starting
> with the letters you typed. Procedures or functions from the local
> file or from files loaded with the load command are displayed with
> their arguments.
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: module_full.png
> Type: image/png
> Size: 151273 bytes
> Desc: not available
> Url :
> http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20110506/24306d2f/attachment.png
> -------------- next part --------------
>
> The completion of resources is not yet implemented, but it will
> follow in the future.
>
> NCL Projects:
> You can open every folder with NCL files as a project, but until now
> it is not possible to create new project folder in Netbeans. To
> create a new project create a new folder and then create an empty
> NCL file inside of this folder. This folder is in Netbeans displayed
> as a project. The module contains a template for new NCL files.
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: PastedGraphic-3.tiff
> Type: image/tiff
> Size: 11452 bytes
> Desc: not available
> Url :
> http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20110506/24306d2f/attachment-0002.tiff
> -------------- next part --------------
>
>
> You can download the plug-in here:
> http://plugins.netbeans.org/plugin/38897/?show=true
>
> Please let me know if you have ideas or Problems.
>
> Robert
>
>
> ------------------------------
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk@ucar.edu <mailto:ncl-talk@ucar.edu>
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
> End of ncl-talk Digest, Vol 90, Issue 8
> ***************************************
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri May 6 14:33:22 2011

This archive was generated by hypermail 2.1.8 : Fri May 13 2011 - 10:21:56 MDT