Closed dlebauer closed 8 years ago
@dlebauer Now we have a python script converting flir data into pngs and geotiffs. Here is an example:
FLIR's pixel value range from 2800 to 3300, I re-scale it to a visible range. My question is:
From the GetFLIR.m file that @TinoDornbusch wrote, I infer that temperature = ((value - 2800) / (3300 - 2800))
Does that produce reasonable values?
@LTBen is this in the protocol for calibrating FLIR data? Can you please share a copy?
From this equation we will get a value normalized in (0, 1), which I used to re-scale it to (0, 255) creating the visible images. This may not be the temperature in degrees C.
I transferred on our findings transformation of FLIR raw values to temperature via Email to the Maricopa team. However it did not end up here. Here it comes:
The output of the FLIR is currently in 100mK. Hence a saved pixel value of 3000 translated into 300K.
FLIR does use a calibration algorithm, which I will post here as MATLAB script. By default this calibration is applied internally by the camera. Hence until now data is already calibrated using a fixed set of parameters, which is now also provided in the FLIR metadata:
"output data format": "16bit Grey",
"calibration available": "calibration parameters from FLIR to convert gray value to temperature",
"sensor computer interface": "GigE",
"sensor id": "ir camera box",
"calibration R": "16923.6",
"calibration B": "1434.6",
"calibration F": "1",
"calibration J1": "70.0704",
"calibration J0": "4124",
"calibration alpha1": "0.006569",
"calibration alpha2": "0.01262",
"calibration X": "1.9",
"calibration beta1": "-0.002276",
"calibration beta2": "-0.00667"
So if an image has a rang 2800 to 3300, that is equivalent to 280-330 K / 27-57 C / 80-134F? The range and max seems high.
Forget about the script GetFLIR.m. This was just a helper to display data. Use FlirRawToTemperature.m.
However, here is the problem: Note that until today all data is already processed an output as 100 mK. If you want to change the calibration using different parameters, you need to "revert" the script, computing back the original 16bit raw pixel values and reapply the script with changed parameters.
Here is the Email conversation I had with scientists at Maricopa. Sorry that this information has not leaked through.
Tino, when is the acceptance test? I am thinking a good cal/val test would rely on a transferred approach, namely use well-calibrated apogee infrared thermometers (do you have any?) in parallel with the FLIR camera. Ive thought about reference field targets but large ones are difficult except for the not-very-practical water ice state. Instead find or make targets with high emissivity, which would be full cover plants , open water (maybe a few ice chests with ambient temperature water; there are some details for this reference that need further discussion…specifically the bulk water temperature can be logged but that temperature is not quite the same as the water skin temperature, the latter subject to evaporative cooling) and wetted bare soil. ALARC has a temperature calibration room that can be used to check calibration of the apogee thermometers at differing ambient and target temperatures. If I am to do this part I would need some tech help, all of these are time consuming tasks. -Andy
Andrew,
Any thoughts on the reference temperature objects? Just want to know whether we can perform some joint measurements during the site acceptance test. You know best that IR cameras are difficult to calibrate & validate.
Thanks for your time Tino
Hi Andrew,
The relatively long lag time is actually a good news for the new campaign. Sounds that we might not need to move the FLIR out of the box south right now.I regard the FLIR data so far not so useful since we scanned along east-west and had shade for about 2min.
We will now also establish a scan mode to scan along north-south. This way shading before imaging is just a couple of seconds.
In Maricopa we briefly talked about blackbodies as temperature reference. We need some references to evaluate the temperature conversion. Any idea how to test FLIR camera best?
Tino
Tino, this sounds like a good plan, i.e. record raw output, also collect Tsens if you can without activating the internal calibration routine.
Today I ran an informal shading test to evaluate temperature change of the soil surface when shading is introduced. I used one of ALARC’s FLIR cameras and found a latency on the order of 30-50 seconds; this is a much greater time than I expected (I had been expecting <10 seconds). I think this observation (and follow-up tests) could be a helpful finding for TERRRA scans. I suspect the long lag time is indicative of high soil moisture conditions and could mean that the deleterious effect of box shading may not be severe for scans if the time between FLIR image collects and onset (or removal) of shading is less than about ½ minute. I realize this time will vary depending on time of day and protocol but do you have a rough idea of lag times for the just-finished sorghum experiment? -Andy
Dear all,
We will set the camera to raw output. Internal Temperature calibration does not make sense. You have no control on parameters, from which ambient temperature and emmisivity have the main impact on temperature conversion. You know better.
Tsens is the temperature on the microbolometer, which FLIR uses for internal calibration. We have no control over that. We can just switch it on/off.
We will add all parameters required for the calibration function in the sensor metadata. Remaining environmental parameters (Relative humidity, ambient temperature, object distance, emissivity) need to be taken from environmental loggers. Humidity is in Maricopa at such short distance no problem (according to FLIR).
Best Tino
Tino, this isn’t my call to decide protocol; but yes Id suggest raw mode and also add Tsens (though not sure what that value means in this context, Sensor body temperature?). –Andy French
Andrew,
Yes it has been a hard time to get the FLIR calibration formulae. Now you can better assess if that procedure is applicable compared to approaches you use.
If you give the OK, I set the FLIR to “raw mode” removing the internal calibration. That you get raw values and can apply any correction formulae you want.
I could only find one temperature value in the FLIR settings that is not preset (TSens; see screenshot). All other relevant parameters -from which temperature and object emissivity are apparently the most important- need to be measured or estimated with other sensors.
If you want, we can add TSens to the variable MetaData of the FLIR.
Best Tino
Tino, this is the first time I’ve seen such equations, thanks for sending along. My experience with FLIR is that they are generally unwilling to share details of the camera calibrations. Ive not been able to extract internal reference temperature, but that would be very helpful to have since that governs the signal from the microbolometer. One suggestion for data collection is to set the target emissivity to 1.0, i.e. blackbody. Then what you have for data are brightness temperatures and one can proceed from there using one’s own skyview factors, surface and sky emissivity estimates. Surface emissivity values can vary a bit- 0.96 is for plants is reasonable though Id choose something closer to 0.97-- and strongly depend upon spectral response of the FLIR camera as well as upon the soil and vegetation fractions. For phenotyping work it may not matter if selected emissivities are inaccurate as long as you the way they are selected is consistent across the experiment. –Andy French
Tino, Thanks for this valuable update which has critical information for processing the FLIR data. Andy French may want to comment on suppressing the internal self-calibration. My impression was that the camera have an internal body reference temperature, which we would need to access. The values of emissivity that you report as being used by FLIR also merit discussion. Apogee’s values for plants are 0.96: http://www.apogeeinstruments.com/emissivity-correction-for-infrared-radiometer-sensors/ The same web page explains the need to consider sky temperature as well. As we discussed previously, a huge issue there is how to deal with the contribution of the instrument box to the net sky temperature. Best regards,
Dear all,
I am not sure how to deal with opening issues at Github, so I use the classical way. Sorry for the late reply, but things were a bit busy here after my long holidays in Maricopa.
We finally figured out the calibration procedures done internally by FLIR IR camera. Please not that FLIR did not want to give us their calibration formulae directly. We got this information indirectly from Rothamsted.
Please find attached on Octave script to transform Raw Pixel values to temperature. I added relevant internal camera parameters. To my understanding, the most important parameter is the object emissivity E, which is set by FLIR to 0.98. Note that there is difference between soil (E=0.93) and vegetation (E=0.98) as given by FLIR.
After some evaluation we found out that the internal calibration was switched on in the FLIR camera. Hence the calculation as stated in the script were already done by the camera. The output of the file is in cK, 3000 cK = 300K = 26.85°C.
I personally would not let make the camera do the calibration internally. You have no control on parameters, especially ambient / atmosphere temperature and object emissivity. That means if you want to recompute raw values for the existing data you need to invert the calibration function.
I would suggest to put the FLIR in Raw mode for the upcoming experiment and use the calibration script.
Hope this is clear and please open a GiTHUB issue for this.
Thanks Tino
HI Tino, Fully understood. I am hoping we can move toward a clear plan for understanding how best to use the system. Best regards, Jeff
Jeff,
I leave a detailed and diplomatic answer to my superiors. Note that I just got involved in the project mid April. Hence I am still in the middle of catching up while following my other duties. Just doing my best to understand and operate the system together with you.
Tino
Tino, In purchasing any imaging system or other complex field instrument, I would expect the provider to provide basic information on calibrations. Depending on the instrument this might consist of a combination of:
Jeff,
What do you mean by ‘LemnaTec formal calibration procedure`?
If you specify the location of the reference panels and visiting frequency, I can program the gantry.
Data analysis is the task of the Danforth team. Solmaz is working on that from LemnaTec side.
You are right, same thing for FLIR thermal camera. We are getting a solution soon.
TIno
https://drive.google.com/drive/folders/0B4JvLJOau3GmR3JRcHZRZEwwR1E This is a very busy time of the year in Maricopa, so we haven’t had a follow-up meeting on the calibration strategy. What I can report to date is:
I didn't realize these were calibrated ... So you recommend turning the FLIR to raw mode and then calculating T?
doing the math of updating previous FLIR images with new parameters should be straightforward if deemed necessary.
I recommend to use raw values. Like this you have all freedom to play with the parameters. Note that the most crucial parameter is the Emissivity, that impacts conversion. Emissivity is different e.g. between soil and plants.
I switched the FLIR to raw output from today on. There is a valueable parameter Tsens (internal FLIR temperature). You can choose, where to measure temperature: Shutter, lens, front
This is currently not included to the Metadata. Do you want us to include this in Metadata? Which Temperature value do you want to output.
What will be most useful? @jeffwhiteaz ?
Temperature Data from FLIR is written to the variable Metadata. Three temperatures are logged: Shutter, Lens, Front. These temperatures can be used in the script to estimate external Optic temperature as parameter required in the FLIR script.
"sensor_fixed_metadata": {
"sensor manufacturer": "FLIR Systems",
"sensor product name": "A645",
"sensor serial number": "13070601",
"sensor description": "IR Sensor 640x480",
"sensor purpose": "measure infrared radiation from soil/crop surface",
"buildin variable optics": "",
"location in gantry system": "camera box, facing ground",
"location in camera box x [m]": "0.877",
"location in camera box y [m]": "1.361",
"location in camera box z [m]": "0.520",
"field of view x [m]": "1.496",
"field of view y [m]": "1.105",
"output data format": "16bit Grey",
"calibration available": "calibration parameters from FLIR to convert gray value to temperature",
"sensor computer interface": "GigE",
"sensor id": "ir camera box",
"calibration R": "16923.6",
"calibration B": "1434.6",
"calibration F": "1",
"calibration J1": "70.0704",
"calibration J0": "4124",
"calibration alpha1": "0.006569",
"calibration alpha2": "0.01262",
"calibration X": "1.9",
"calibration beta1": "-0.002276",
"calibration beta2": "-0.00667"
},
"sensor_variable_metadata": {
"current setting AutoFocus": "1",
"current setting Manual focal length [cm]": "195",
"camera info": "A645,Gen_A/G,GEV,1.0.0,GEV,1.2.17 (13070601)",
"focus distance [m]": "2.021",
"lens temperature [K]": "306.499",
"shutter temperature [K]": "306.193",
"front temperature [K]": "307.094"
}
In response to my query to Andy French about the best ttemperature to use, Andy responded: Ideally the reference temperature is the detector temperature, not the lens temperature or shutter temperature , but that temperature is better than ambient air temperature. But I cannot believe FLIR doesn’t incorporate detector temperature in their calibration, which means that I could be accessible if FLIR wants it to be. Alternatively try to thermally isolate (not insulate) the FLIR so that the optic train temperature is close to or correlated to the detector temperature. Metadata recording of this temperature a very good idea. -Andy
Do we know what the "front" temperature actually measures? It sounds like the body surrounding the lens, but it would to know for sure.
@TinoDornbusch The calibration parameters have been in the metadata since at least 08/28, but were not there on 08/03.
When were the files changed from mK to radiance? Is this information included in the metadata?
Internal FLIR calibration has been changed to raw at 15.9.2016....Do you want us to enter a note in sensor_fixed_metaData, such as:
"sensor_fixed_metadata": { "comment sensor output": "Sensor output with internal FLIR calibration in 100mK until 14.9.2016, since 15.9.2016 without calibration in raw 16bit unsigned integer",
@dlebauer PLease specify which notification on FLIR Metadata you would like to indicate the change in output data format.
Uploaded python script to convert flir binfile
@ZongyangLi could you suggest a solution to @TinoDornbusch (see two comments starting with https://github.com/terraref/computing-pipeline/issues/151#issuecomment-247756163) regarding how to describe in metadata the calibrated vs. uncalibrated data (presumably in a way that your script can handle)?
@dlebauer Is that means @TinoDornbusch can provide a parameter in json file indicates whether data in binfile is a 'calibrated' or 'uncalibrated'? If yes, my suggestion is
"sensor_fixed_metadata": {
"output type": "calibrated" / "raw"
}
Is that make sense?
And thanks for reminding that the calibration metadata is in the new json file, I will update the script
@ZongyangLi how about
"sensor_fixed_metadata": {
"calibrated": "true"
}
@dlebauer That's good for me.
To confirm: You want us to put in all sensor metadata a statement, whether it is calibrated.
"sensor_fixed_metadata": { "calibrated": "true" or "false" }
I think it is only necessary for FLIR. On Thu, Oct 6, 2016 at 3:54 AM TinoDornbusch notifications@github.com wrote:
To confirm: You want us to put in all sensor metadata a statement, whether it is calibrated.
"sensor_fixed_metadata": { "calibrated": "true" or "false" }
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/terraref/computing-pipeline/issues/151#issuecomment-251904261, or mute the thread https://github.com/notifications/unsubscribe-auth/AAcX58slA_axG7RVymwf-jfcNxyNTL_Zks5qxLc4gaJpZM4Jo3xN .
@ZongyangLi the script looks good. I think it should be fairly easy to put this into an extractor for Clowder. Basically you just need to add a bit of python code using pyClowder. An example is how I took this python demosaic script: https://github.com/terraref/computing-pipeline/tree/master/scripts/stereoImager ...and added extractor files to call that script when files are uploaded into Clowder: https://github.com/terraref/extractors-stereo-rgb/tree/master/demosaic
I think it would be a good exercise to try writing this extractor, or at least a first version of it I can help clean up. You could use my demosaic version as a template. You can learn more about extractors here:
I or possibly @robkooper can help answer questions as you go, but getting this started would help move this along while I finish up other things in the meantime. Please take a look and let me know what you think.
@max-zilla Thanks! I will follow your advise to put it into extractor.
@dlebauer mention that this does not need an extractor, so I didn't upload a clowder extractor script. If an extractor is needed, I will follow the examples in demosaic to write a first version of flir extractor.
@max-zilla Hi, I am testing flir extractor in my laptop, but the clowder develop version in my laptop do not support the input of 'mountedPaths'. Could you give me a new version that I can test in my laptop?
@ZongyangLi the mountedPaths is only necessary for local paths - you could remove it and add it back later if that solves the error. I can help with that part at the end.
But if you want to fix, I think you just need to install the branch of PyClowder where I added the mountedPath support (which lets extractors locate files on locally mounted directories instead of downloading if possible). Clone this repo (or go to where you've cloned it previously): https://opensource.ncsa.illinois.edu/bitbucket/projects/CATS/repos/pyclowder then
git checkout local-mount-path-downloading
python setup.py install
This will install my branch which knows how to handle the mountedPaths.
You probably don't need to modify Clowder itself unless you're running a very old version.
@max-zilla This first version of flir extractor works in my testing environment now. Could you please help me checking whether it works in other environment?
https://github.com/terraref/computing-pipeline/tree/demosaic_extractor/scripts/FLIR
@max-zilla do you think you can maybe take the wordcount extractor from pyclowder2 and use that to write a a single page here on the wiki how to get started.
@max-zilla by wiki I think Rob is referring to https://github.com/terraref/documentation/blob/master/developing-clowder-extractors.md
Started working on documentation on the Clowder wiki that we can link to from TERRA documentation so we don't have to write it twice: https://opensource.ncsa.illinois.edu/confluence/display/CATS/Extractor+Development
@ZongyangLi I will test out the extractor before our meeting on Thursday this week. Thanks!
@ZongyangLi do you know when your test data is from? I downloaded a flirIr dataset from Oct 11 (2016-10-11__08-26-24-955) and got errors running extractor:
getting information from json file
Metadata file missing key: position x [m]
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/local/lib/python2.7/site-packages/pyclowder/extractors.py", line 350, in thread_function_dataset
_processFileFunction(jbody)
File "terra_flir.py", line 116, in process_dataset
center_position, scan_time, fov = getFlir.parse_metadata(metadata)
File "Get_FLIR.py", line 366, in parse_metadata
position = [float(gantry_x), float(gantry_y), float(gantry_z)]
UnboundLocalError: local variable 'gantry_x' referenced before assignment
This is due to the obviously missing data in metadata file:
"gantry_system_variable_metadata": {
"only small set of meta data available": "measurement was done during sensor setup",
"timestamp": "10/11/2016 08:26:24",
"PLC control not available": "no gantry position data"
},
Have you heard anything about PLC control not available? I'm wondering if I missed a change or news that something was temporarily down...
(for this wondering, the specific code that failed is:
try:
gantry_meta = metadata['lemnatec_measurement_metadata']['gantry_system_variable_metadata']
gantry_x = gantry_meta["position x [m]"]
gantry_y = gantry_meta["position y [m]"]
gantry_z = gantry_meta["position z [m]"]
except KeyError as err:
fail('Metadata file missing key: ' + err.args[0])
...
)
@max-zilla Sorry, I didn't notice these missing data in metadata, my bad.
I have no idea about these"PLC control not available", I think I should add some code to avoid these fail.
@ZongyangLi seems like we SHOULD fail there, at least more gracefully. we can't generate the geotiff without position right?
@max-zilla Yes, you are right. We can't generate the geotiff without Gantry position.
Should we just return "empty" instead of letting the extractor fail?
@ZongyangLi I think we want to fail on the extractor... unless we want to generate the PNG images, doesn't look like those need position.
Not really sure what else we can do, if the PLC control was missing when it was captured I don't know how we can go back and recover that information later that will allow us to re-run the extractor once it's fixed. I think all we can do on TIFF is fail.
@jdmaloney I have created a VM for this extractor on Roger.
/sites/ua-mac/raw_data
/sites/ua-mac/Level_1/flirIrCamera
Can you possibly set up the bindings before you're out at the end of the week? Thanks.
@max-zilla Yeah, I'll get this done here today or tomorrow. I'm prepping the ROGER system today for it's maintenance tomorrow, I'll work to get this in there as well.
We will deploy with just PNG functional and can generate the TIF later.
POSSIBLE SOLUTION: flirIr camera is running at the same time as stereoCamera so we can compare timestamps and get location from stereoCamera if we have a match. thanks @solmazhajmohammadi
@jdmaloney today while you create exports for the FLIR export up there, can you also create exports for the new geospatial VM I created?
IP - 141.142.170.182
reads
/sites/ua-mac/raw_data
This doesn't need to write anything, it pushes metadata to Clowder and geostreams.
Thanks, I can bug your neighbor Chad about these things next week if he's the right person too and you're out of time.
@ZongyangLi I made some modifications to address the missing data issue above: https://github.com/terraref/extractors-multispectral/pull/2/files
Basically just return None for the parse_metadata() results, and in the extractor if None is returned we skip the GeoTIFF portion. The PNG file is still generated and uploaded. I added this check to your get_flir() method as well so this error should be avoided even when run from command line.
I sent a message to @dlebauer asking to create the necessary output folder on Roger, then I'll go ahead and merge the PR + deploy it.
@max-zilla I have review those codes. it's great! Thanks!
Extractor has been deployed and a test extraction was verified: https://github.com/terraref/extractors-multispectral
New FLIR outputs will appear in ua-mac/sites/Level_1/flirIrCamera as they arrive via Globus. Some point soon we'll initiate processing of backlog for all these extractors.
Description
Convert NDVI binary files to png thumbnail + geoTIFF or netCDF raster data product.
(Updated Sept 16 2016)
For data generated through Sept (?15?) 2016 (provided in units of mK)
T(C) = x/100,000 - 273.15
)for data generated as radiance values
Steps:
This is a subtask of #64