       unless @collection.hasExtent
         mins = @collection.map( (l) -> return l.get('minimum'))
         maxs = @collection.map( (l) -> return l.get('maximum'))
-        globalMin = Math.min.apply(Math, mins)
-        globalMax = Math.max.apply(Math, maxs)
-        @wfits.setExtent(globalMin, globalMax)
+        @min = Math.min.apply(Math, mins)
+        @max = Math.max.apply(Math, maxs)
+        @wfits.setExtent(@min, @max)
         @collection.hasExtent = true
       
       @wfits.setImage(band)

    console.log 'allChannelsReceived'
    @dfs = undefined
    
    @computeNormalizedScales()
    scales = @collection.getColorScales()
    
    @wfits.setCalibrations(1, 1, 1)

    @stretch = value
    @wfits.setStretch(value)

  getExtent: (value) ->
    return (@max - @min) * value / 1000

  updateExtent: (min, max) =>
    min = @getExtent(min)
    max = @getExtent(max)
    @wfits.setExtent(min, max)


window.Ubret.SpacewarpViewer = SpacewarpViewer
