Blue Carbon runtime error

Hello,

I am getting a runtime error when I attempt to run the Blue Carbon model and can not figure out what exactly the issue is.  The error is:

\output\intermediate\2002_2025_veg_2_dis_bio.tif, band 1: Failed to compute statistics, no valid pixels found in sampling


The error occurrs after the model begins "Processing vegetation type 2".  The area that I am covering is entirely salt marsh so there is no type 2 vegetation represented, I don't know if that is part of the issue or not.  Any help would be greatly appreciated, I have hit the wall with this.  Also, I ran the same set of parameters in both 3.0.1 and 3.1.0 and got the error with both models.

Comments

  • Additionally, I ran a few other sets of rasters from the same SLAMM output and am getting the same error.
  • DougDoug Administrator, NatCap Staff
    Hi,

    Could you post the error log generated from the model run? The model will create a log file in the workspace on every run. Pasting or attaching is fine!

    Thanks!

  • Hi Doug,

    I have attached two different logs.  The first is the original issue I was commenting on, the other is another error that I am now getting regularly when I try different rasters.  The KeyError: '' run time error is one that I have gotten on two different computers in both 3.0.1 and 3.1.0.  I am using all of the original .csv files save for the transition matrix and some changed values in the carbon table, so it seems like the issue may be arising either from the rasters or the model itself?  Thanks for looking into this for me, I appreciate it.

    Best,

    Amelia

  • DougDoug Administrator, NatCap Staff
    Just took a quick look and the second issue with the KeyError seems to be coming from handling the transition matrix, generated from the preprocessor. The initial issue is a bit harder to debug, but one of the rasters being calculated / generated is getting messed up with values.

    I believe @gverutes is the owner of this model. Maybe he can provide some insight and help.

    Ultimately I think if possible, we'll need to get your data to reproduce the problem on our end and really dive into it.
  • AOwre21AOwre21 Member
    edited February 2015

    Ok, thanks for taking a look.  I can get my data to you either via Google Drive or Dropbox, is there an email I can send the link to?

    Also, do you have any tips on things to check for in the transition matrix that might be causing the KeyError?

    Post edited by AOwre21 on
  • WillBWillB NatCap Staff
    Hi Amelia,

    Would you be able to share your data to wbierbow@stanford.edu?  Either Google Drive or Dropbox works great.  I'll be in touch with Gregg to see what tips we can give about the transition matrix.

    Thanks!

    Will

  • WillBWillB NatCap Staff
    Hi Amelia,

    In the hope of a simple fix --

    One possible source for the error could involve the fact that the transition.csv file generated by the preprocessor must be manually edited before being submitted to the main program.

    All the "Disturbance" entries in the table need to be prepended with "Low", "Medium", or "High" - corresponding to columns in the biomass_disturbance.csv and soil_disturbance.csv files.

    Did you happen to make those edits?  If so, I'll try to look into the issue more when I get your data.

    Best,
    Will

  • Hi Will,

    I did modify the Disturbance entries to "Medium Disturbance", but your comment got me thinking.  I realized that as I did different model runs, I did not consistently clear the cells that direct you to make those changes to Disturbance (below the transition matrix itself).  Once I deleted the contents of those cells, the model ran (up to the point of the "Failed to compute statistics" error, that is still an issue).  So one issue down, one to go!  I have emailed you a link to the Google Drive folder with my data, please let me know if it does not come through or if there is something missing.  I appreciate you taking the time to look into this for me, thanks again!

    Best,

    Amelia

  • WillBWillB NatCap Staff
    Hi Amelia,

    It looks like the issue was that the transition.csv file requires an extra empty line at the bottom of the file to be properly parsed.  I've attached a version that should allow your model to run to completion.

    Let us know if that doesn't solve the issue!

    Best,
    Will

  • Hi Will,

    Unfortunately, I am still getting the same error, even when I use the transition matrix that you guys provided.  Were you able to get the model to run successfully on your end with that .csv?  Thanks for the help!

    Best,

    Amelia

  • WillBWillB NatCap Staff
    Hi Amelia,

    Yes, I apologize.  The issue does still exist on InVEST version 3.1.   The model does however run to completion on this development build (clicking the link will trigger a download):  http://130.211.163.122/~dataportal/nightly-build/InVEST_dev81_3_1_0b1 [b8649bd25392]_x86_Setup.exe

    Thanks for your persistence!  We really appreciate you letting us know about this issue.

    Best,
    Will

  • Well, it looked like it was going to work...the model did not hang up in the beginning like it had before, but unfortunately there are still issues.  It ran almost to the end but ended up exiting for a new error "NameError: global name 'carbon_conversion' is not defined".  I have attached the error log.  Also, since the model did get almost to the end, it looked like the output rasters had populated.  However, when I imported them into ArcGIS, they did not actually have any data in them.  All of the pixels have a value of 0.  In the Google Drive folder that I shared with you, you can find the output for this run in the folder "Dev Run".

  • For some more info on this, I watched the run window while the model was progressing, and it appeared that there was a continuous "...Failed to compute statistics, no valid pixels found in sampling" error occurring during processing, though it did not cause the model to exit.
     
  • DougDoug Administrator, NatCap Staff
    Hey there, I wonder if the second issue is due to the first. The first issue seems to be a simple bug that hopefully can be fixed soon!

    We'll post back here with an update and a patch soon.

    Thanks for your patience
  • gverutesgverutes Moderator, NatCap Staff
    Amelia,
    One thing you can fix in the mean time is that you define 24 LULC classes in the carbon.csv table but there are only 16 classes in the input TIFs (2000-2100) and the resulting transition matrix produced by the pre-processor.  Please remove the extra classes from carbon.csv that are not found in the maps.  For example, you define mangroves (class 9), but I don't see this class in the maps.  The model is trying to compute accumulation and disturbance for a vegetation (type 2) that doesn't exist.

    Cheers,
    Gregg
  • Thanks Doug and Gregg for the feedback.  I made the mods to the carbon table but still get the same error, so I will wait for the update and patch.
  • AOwre21AOwre21 Member
    edited February 2015
    So I wanted to give a quick update about what I found after some more troubleshooting, just in case the additional info could be of help.  When I promoted the pixel depth of my rasters from 8 to 16 bit and made my no data value 128 instead of 0, I was able to get the model to create gain, loss, sequestration and stock output rasters with actual data in them.  However, I was still getting "NameError: global name 'carbon_conversion' is not defined", the final core report was blank, and I did not have any NPV rasters.  For reference, I was attempting to do a valuation using a carbon value and annual rate of change instead of a price table.  The missing NPV rasters led me to believe that the issue was stemming from the valuation piece.  When I unchecked that box, I was in fact able to run the model to completion and the core report was populated.  So the carbon stock and sequestration part seems to be resolved on my end, it is just the valuation component outstanding.
    Post edited by AOwre21 on
  • WillBWillB NatCap Staff
    Hi Amelia,

    I apologize for the lengthy delay -- thank you very much for the update!

    It appears that the issue with the input LULC rasters has to do with the zero-value for NoData rather than the raster's pixel data type. For now, you should be able to assign any positive number greater than the highest LULC category to allow the model to run to completion (e.g. a value between 24 and 255 in UInt8).

    As for the valuation issue, that is a separate bug that has been fixed in this development version of InVEST: http://130.211.163.122/~dataportal/nightly-build/release_tip/InVEST_dev270_3_1_0b1 [efa7675654e9]_x86_Setup.exe

    I hope this fixes your issue, but please don't hesitate to follow up.  Thanks again for your patience!

    Will

  • Hi Will,

    When I ran the development version I did not get any actual outputs for valuation, though the model did run to completion.  In addition the core report is missing.  I tried running it with the default rasters and tables as well just to see what the output would be, and had the same result.  I also tried the new build 3.1.1, and again had the same result.  I thought there were supposed to be valuation rasters or at least an output table, am I missing something?
  • WillBWillB NatCap Staff
    Hi Amelia,

    I just want to say thank you for hanging in there.

    Here's a version of the model that runs to completion, outputs complete rasters, and outputs the core report.


    Here's what it needs from you:
    * Reclassify your nodata values to something besides 0 and not your LULC values -- I ran your data successfully with 100.
    * Replace the top row in your carbon.csv file with the following line (units have been edited during development):
    Id,Name,Veg Type,Above (MtCO2e / ha),Below (MtCO2e / ha),Soil (MtCO2e / ha-m),Litter (MtCO2e / ha),Bio_accum_rate (MtCO2e / ha-yr),Soil_accum_rate (MtCO2e / ha-yr)

    And that should be it. I'd be happy to send you a Dropbox folder of the run if that's of any help to you.

    Best,
    Will
Sign In or Register to comment.