avaframe/AvaFrame

View on GitHub
avaframe/ana5Utils/distanceTimeAnalysis.py

Summary

Maintainability
F
3 days
Test Coverage
C
78%

File distanceTimeAnalysis.py has 591 lines of code (exceeds 300 allowed). Consider refactoring.
Open

""" functions to convert to a different coordinate system and
    produce a range-time diagram from simulation results
    options:
    1) range-time diagram from radar's field of view capped to this
    2) thalweg-time diagram from beta point of view along avalanche path
Severity: Major
Found in avaframe/ana5Utils/distanceTimeAnalysis.py - About 1 day to fix

    Function extractFrontAndMeanValuesTT has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def extractFrontAndMeanValuesTT(cfgRangeTime, flowF, demHeader, mtiInfo):
        """ extract avalanche front and mean values of flow parameter result field
            used for colorcoding range-time diagram
    
            Parameters
    Severity: Minor
    Found in avaframe/ana5Utils/distanceTimeAnalysis.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function extractFrontAndMeanValuesRadar has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def extractFrontAndMeanValuesRadar(cfgRangeTime, flowF, mtiInfo):
        """ extract average values of flow parameter result at certain distance intervals (range gates)
            add info to be used for colorcoding range-time diagram
    
            Parameters
    Severity: Minor
    Found in avaframe/ana5Utils/distanceTimeAnalysis.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function approachVelocity has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def approachVelocity(mtiInfo):
        """ compute maximal approach velocity based on front location (range) and time step
    
            - cleans nan in range
            - neglects anything behind maximal runout
    Severity: Minor
    Found in avaframe/ana5Utils/distanceTimeAnalysis.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function fetchRangeTimeInfo has 7 arguments (exceeds 6 allowed). Consider refactoring.
    Open

    def fetchRangeTimeInfo(cfgRangeTime, cfg, dtRangeTime, t, demHeader, fields, mtiInfo):
    Severity: Major
    Found in avaframe/ana5Utils/distanceTimeAnalysis.py - About 35 mins to fix

      Function importMTIData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def importMTIData(avaDir, modName, inputDir='', simHash=''):
          """ import mtiInfo data for creating range time plots, if no inputDir is provided,
              pickles are fetched from avaDir/Outputs/modName/distanceTimeAnalysis
              multiple pickles allowed- these carry also configuration info for distanceTimeAnalysis
      
      
      Severity: Minor
      Found in avaframe/ana5Utils/distanceTimeAnalysis.py - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function setupThalwegTimeDiagram has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def setupThalwegTimeDiagram(dem, cfgRangeTime):
          """ initialize parameters and prerequisites for generating thalweg-time diagrams
      
              Parameters
              -----------
      Severity: Minor
      Found in avaframe/ana5Utils/distanceTimeAnalysis.py - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              if cfgRangeTime['PLOTS'].getboolean('animate'):
                  mtiInfo['slRaster'] = slRaster
                  mtiInfo['rasterTransfo'] = rasterTransfo
                  mtiInfo['cLower'] = cLower
      Severity: Major
      Found in avaframe/ana5Utils/distanceTimeAnalysis.py and 1 other location - About 1 hr to fix
      avaframe/ana5Utils/distanceTimeAnalysis.py on lines 538..541

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 49.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              if cfgRangeTime['PLOTS'].getboolean('animate'):
                  mtiInfo['slRaster'] = slRaster
                  mtiInfo['rasterTransfo'] = rasterTransfo
                  mtiInfo['cLower'] = cLower
      Severity: Major
      Found in avaframe/ana5Utils/distanceTimeAnalysis.py and 1 other location - About 1 hr to fix
      avaframe/ana5Utils/distanceTimeAnalysis.py on lines 545..548

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 49.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

          mtiInfo['textbox'] = 'beta point: %.2f, %.2f' % (mtiInfo['betaPoint'][0],
                                                           mtiInfo['betaPoint'][1])
      Severity: Major
      Found in avaframe/ana5Utils/distanceTimeAnalysis.py and 1 other location - About 1 hr to fix
      avaframe/ana5Utils/distanceTimeAnalysis.py on lines 594..595

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 44.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              mtiInfo['textbox'] = 'beta point: %.2f, %.2f' % (mtiInfo['betaPoint'][0],
                                                               mtiInfo['betaPoint'][1])
      Severity: Major
      Found in avaframe/ana5Utils/distanceTimeAnalysis.py and 1 other location - About 1 hr to fix
      avaframe/ana5Utils/distanceTimeAnalysis.py on lines 64..65

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 44.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          rD, phiD, thetaD = gT.cartToSpherical(X=rDx-rX, Y=rDy-rY, Z=rDz-rZ)
      Severity: Major
      Found in avaframe/ana5Utils/distanceTimeAnalysis.py and 1 other location - About 1 hr to fix
      avaframe/ana5Utils/distanceTimeAnalysis.py on lines 249..249

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 41.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          r, phi, theta = gT.cartToSpherical(X=X-rX, Y=Y-rY, Z=rasterdata-rZ)
      Severity: Major
      Found in avaframe/ana5Utils/distanceTimeAnalysis.py and 1 other location - About 1 hr to fix
      avaframe/ana5Utils/distanceTimeAnalysis.py on lines 246..246

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 41.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

          elif cfgRangeTime['GENERAL']['sType'].lower() == 'projected':
              if cfgRangeTime['GENERAL'].getboolean('originStart'):
                  rangeGates = rasterTransfo['s'][:]
              else:
                  rangeGates = rasterTransfo['s'][:] - rasterTransfo['s'][indStartOfRunout]
      Severity: Minor
      Found in avaframe/ana5Utils/distanceTimeAnalysis.py and 1 other location - About 50 mins to fix
      avaframe/ana5Utils/distanceTimeAnalysis.py on lines 526..535

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 36.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              elif mtiInfo['sType'].lower() == 'projected':
                  if cfgRangeTime['GENERAL'].getboolean('originStart'):
                      rangeValue = rasterTransfo['s'][cLower]
                  else:
                      rangeValue = rasterTransfo['s'][cLower] - rasterTransfo['s'][indStartOfRunout]
      Severity: Minor
      Found in avaframe/ana5Utils/distanceTimeAnalysis.py and 1 other location - About 50 mins to fix
      avaframe/ana5Utils/distanceTimeAnalysis.py on lines 435..444

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 36.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 10 locations. Consider refactoring.
      Open

              if mtiInfo['sType'].lower() == 'parallel':
                  rangeValue = rasterTransfo['sParallel'][cLower] - rasterTransfo['sParallel'][indStartOfRunout]
      Severity: Major
      Found in avaframe/ana5Utils/distanceTimeAnalysis.py and 9 other locations - About 45 mins to fix
      avaframe/ana1Tests/energyLineTest.py on lines 251..251
      avaframe/ana1Tests/energyLineTest.py on lines 252..252
      avaframe/ana5Utils/distanceTimeAnalysis.py on lines 527..530
      avaframe/out3Plot/outAIMEC.py on lines 1186..1186
      avaframe/out3Plot/outAIMEC.py on lines 1187..1187
      avaframe/out3Plot/outAIMEC.py on lines 1307..1307
      avaframe/out3Plot/outAIMEC.py on lines 1308..1308
      avaframe/out3Plot/outAIMEC.py on lines 1310..1310
      avaframe/out3Plot/outAIMEC.py on lines 1311..1311

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 35.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 10 locations. Consider refactoring.
      Open

                  if cfgRangeTime['GENERAL'].getboolean('originStart'):
                      rangeValue = rasterTransfo['s'][cLower]
                  else:
                      rangeValue = rasterTransfo['s'][cLower] - rasterTransfo['s'][indStartOfRunout]
      Severity: Major
      Found in avaframe/ana5Utils/distanceTimeAnalysis.py and 9 other locations - About 45 mins to fix
      avaframe/ana1Tests/energyLineTest.py on lines 251..251
      avaframe/ana1Tests/energyLineTest.py on lines 252..252
      avaframe/ana5Utils/distanceTimeAnalysis.py on lines 524..525
      avaframe/out3Plot/outAIMEC.py on lines 1186..1186
      avaframe/out3Plot/outAIMEC.py on lines 1187..1187
      avaframe/out3Plot/outAIMEC.py on lines 1307..1307
      avaframe/out3Plot/outAIMEC.py on lines 1308..1308
      avaframe/out3Plot/outAIMEC.py on lines 1310..1310
      avaframe/out3Plot/outAIMEC.py on lines 1311..1311

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 35.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              if cfgRangeTime['GENERAL'].getboolean('originStart'):
                  rangeGates = rasterTransfo['s'][:]
              else:
                  rangeGates = rasterTransfo['s'][:] - rasterTransfo['s'][indStartOfRunout]
      Severity: Minor
      Found in avaframe/ana5Utils/distanceTimeAnalysis.py and 1 other location - About 35 mins to fix
      avaframe/ana5Utils/distanceTimeAnalysis.py on lines 433..434

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 33.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          if cfgRangeTime['GENERAL']['sType'].lower() == 'parallel':
              rangeGates = rasterTransfo['sParallel'][:] - rasterTransfo['sParallel'][indStartOfRunout]
      Severity: Minor
      Found in avaframe/ana5Utils/distanceTimeAnalysis.py and 1 other location - About 35 mins to fix
      avaframe/ana5Utils/distanceTimeAnalysis.py on lines 436..439

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 33.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      There are no issues that match your filters.

      Category
      Status